mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:28:11 +00:00
LibWeb: Reflect only known values for <input> element's type attribute
This commit is contained in:
parent
a9dbb52deb
commit
8edade071d
2 changed files with 38 additions and 4 deletions
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
|
||||||
|
* Copyright (c) 2022, Adam Hodgen <ant1441@gmail.com>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -229,11 +230,18 @@ void HTMLInputElement::did_remove_attribute(FlyString const& name)
|
||||||
|
|
||||||
String HTMLInputElement::type() const
|
String HTMLInputElement::type() const
|
||||||
{
|
{
|
||||||
// FIXME: This should only reflect known values.
|
|
||||||
auto value = attribute(HTML::AttributeNames::type);
|
auto value = attribute(HTML::AttributeNames::type);
|
||||||
if (value.is_null())
|
|
||||||
return "text";
|
#define __ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(keyword) \
|
||||||
return value;
|
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)
|
void HTMLInputElement::set_type(String const& type)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
|
||||||
|
* Copyright (c) 2022, Adam Hodgen <ant1441@gmail.com>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -11,6 +12,31 @@
|
||||||
|
|
||||||
namespace Web::HTML {
|
namespace Web::HTML {
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/input.html#attr-input-type
|
||||||
|
#define ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTES \
|
||||||
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(hidden) \
|
||||||
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(text) \
|
||||||
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(search) \
|
||||||
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(tel) \
|
||||||
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(url) \
|
||||||
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(email) \
|
||||||
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(password) \
|
||||||
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(date) \
|
||||||
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(month) \
|
||||||
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(week) \
|
||||||
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(time) \
|
||||||
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE("datetime-local") \
|
||||||
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(number) \
|
||||||
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(range) \
|
||||||
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(color) \
|
||||||
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(checkbox) \
|
||||||
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(radio) \
|
||||||
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(file) \
|
||||||
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(submit) \
|
||||||
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(image) \
|
||||||
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(reset) \
|
||||||
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(button)
|
||||||
|
|
||||||
class HTMLInputElement final : public FormAssociatedElement {
|
class HTMLInputElement final : public FormAssociatedElement {
|
||||||
public:
|
public:
|
||||||
using WrapperType = Bindings::HTMLInputElementWrapper;
|
using WrapperType = Bindings::HTMLInputElementWrapper;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue