diff options
author | Andreas Kling <kling@serenityos.org> | 2022-02-17 13:12:01 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-02-17 16:33:55 +0100 |
commit | 2660795bcf553351fdf1dd61fa673ffe689c528e (patch) | |
tree | 1dc4493f99050bb213754a876caa3699da6bd94e | |
parent | 5f54b8dd6ca114e9b867958f0a64b7b190d47a74 (diff) | |
download | serenity-2660795bcf553351fdf1dd61fa673ffe689c528e.zip |
LibWeb: Add the HTMLInputElement.type attribute
This makes React react to change events on text <input> elements. :^)
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp | 14 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/HTMLInputElement.h | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl | 2 |
3 files changed, 19 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 4935f8d3d3..26769cd652 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -219,4 +219,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; +} + +void HTMLInputElement::set_type(String const& type) +{ + set_attribute(HTML::AttributeNames::type, type); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h index 7a5265ac05..2a96aceb66 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h @@ -20,7 +20,9 @@ public: virtual RefPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override; - String type() const { return attribute(HTML::AttributeNames::type); } + String type() const; + void set_type(String const&); + String default_value() const { return attribute(HTML::AttributeNames::value); } String name() const { return attribute(HTML::AttributeNames::name); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl index b8ed3705df..e4f1b9083c 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl @@ -17,6 +17,8 @@ interface HTMLInputElement : HTMLElement { [Reflect=dirname] attribute DOMString dirName; [Reflect=value] attribute DOMString defaultValue; + attribute DOMString type; + [LegacyNullToEmptyString] attribute DOMString value; attribute boolean checked; |