mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 22:38:51 +00:00
LibWeb: Reflect only known values for <input> element's type attribute
This commit is contained in:
parent
a9dbb52deb
commit
8edade071d
Notes:
sideshowbarker
2024-07-18 00:54:03 +09:00
Author: https://github.com/ant1441
Commit: 8edade071d
Pull-request: https://github.com/SerenityOS/serenity/pull/12612
2 changed files with 38 additions and 4 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2022, Adam Hodgen <ant1441@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -229,11 +230,18 @@ void HTMLInputElement::did_remove_attribute(FlyString const& name)
|
|||
|
||||
String HTMLInputElement::type() const
|
||||
{
|
||||
// FIXME: This should only reflect known values.
|
||||
auto value = attribute(HTML::AttributeNames::type);
|
||||
if (value.is_null())
|
||||
return "text";
|
||||
return value;
|
||||
|
||||
#define __ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(keyword) \
|
||||
if (value.equals_ignoring_case(#keyword)) \
|
||||
return #keyword;
|
||||
ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTES
|
||||
#undef __ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE
|
||||
|
||||
// The missing value default and the invalid value default are the Text state.
|
||||
// https://html.spec.whatwg.org/multipage/input.html#the-input-element:missing-value-default
|
||||
// https://html.spec.whatwg.org/multipage/input.html#the-input-element:invalid-value-default
|
||||
return "text";
|
||||
}
|
||||
|
||||
void HTMLInputElement::set_type(String const& type)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue