mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-03 17:58:49 +00:00
LibWeb: Implement the HTMLOutputElement.htmlFor
attribute
This returns a DOMTokenList that reflects the `for` attribute.
This commit is contained in:
parent
acc1fa3c62
commit
3dc86747f0
Notes:
sideshowbarker
2024-07-17 03:03:37 +09:00
Author: https://github.com/tcl3
Commit: 3dc86747f0
Pull-request: https://github.com/SerenityOS/serenity/pull/24344
Reviewed-by: https://github.com/shannonbooth ✅
5 changed files with 61 additions and 1 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <LibWeb/Bindings/HTMLOutputElementPrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/DOM/DOMTokenList.h>
|
||||
#include <LibWeb/HTML/HTMLOutputElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -25,6 +26,29 @@ void HTMLOutputElement::initialize(JS::Realm& realm)
|
|||
WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLOutputElement);
|
||||
}
|
||||
|
||||
void HTMLOutputElement::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_html_for);
|
||||
}
|
||||
|
||||
void HTMLOutputElement::form_associated_element_attribute_changed(FlyString const& name, Optional<String> const& value)
|
||||
{
|
||||
if (name == HTML::AttributeNames::for_) {
|
||||
if (m_html_for)
|
||||
m_html_for->associated_attribute_changed(value.value_or(String {}));
|
||||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-output-htmlfor
|
||||
JS::NonnullGCPtr<DOM::DOMTokenList> HTMLOutputElement::html_for()
|
||||
{
|
||||
// The htmlFor IDL attribute must reflect the for content attribute.
|
||||
if (!m_html_for)
|
||||
m_html_for = DOM::DOMTokenList::create(*this, HTML::AttributeNames::for_);
|
||||
return *m_html_for;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-output-defaultvalue
|
||||
String HTMLOutputElement::default_value() const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue