@@ -210,7 +210,7 @@ GC::Ptr<Attr> Element::get_attribute_node_ns(Optional<FlyString> const& namespac
210210
211211// FIXME: Trusted Types integration with DOM is still under review https://github.com/whatwg/dom/pull/1268
212212// https://whatpr.org/dom/1268.html#dom-element-setattribute
213- WebIDL::ExceptionOr<void > Element::set_attribute (FlyString qualified_name, Variant<GC::Root<TrustedTypes::TrustedHTML>, GC::Root<TrustedTypes::TrustedScript>, GC::Root<TrustedTypes::TrustedScriptURL>, Utf16String> const & value)
213+ WebIDL::ExceptionOr<void > Element::set_attribute_for_bindings (FlyString qualified_name, Variant<GC::Root<TrustedTypes::TrustedHTML>, GC::Root<TrustedTypes::TrustedScript>, GC::Root<TrustedTypes::TrustedScriptURL>, Utf16String> const & value)
214214{
215215 // 1. If qualifiedName is not a valid attribute local name, then throw an "InvalidCharacterError" DOMException.
216216 if (!is_valid_attribute_local_name (qualified_name))
@@ -245,9 +245,9 @@ WebIDL::ExceptionOr<void> Element::set_attribute(FlyString qualified_name, Varia
245245
246246// FIXME: Trusted Types integration with DOM is still under review https://github.com/whatwg/dom/pull/1268
247247// https://whatpr.org/dom/1268.html#dom-element-setattribute
248- WebIDL::ExceptionOr<void > Element::set_attribute (FlyString qualified_name, Variant<GC::Root<TrustedTypes::TrustedHTML>, GC::Root<TrustedTypes::TrustedScript>, GC::Root<TrustedTypes::TrustedScriptURL>, String> const & value)
248+ WebIDL::ExceptionOr<void > Element::set_attribute_for_bindings (FlyString qualified_name, Variant<GC::Root<TrustedTypes::TrustedHTML>, GC::Root<TrustedTypes::TrustedScript>, GC::Root<TrustedTypes::TrustedScriptURL>, String> const & value)
249249{
250- return set_attribute (move (qualified_name),
250+ return set_attribute_for_bindings (move (qualified_name),
251251 value.visit (
252252 [](auto const & trusted_type) -> Variant<GC::Root<TrustedTypes::TrustedHTML>, GC::Root<TrustedTypes::TrustedScript>, GC::Root<TrustedTypes::TrustedScriptURL>, Utf16String> { return trusted_type; },
253253 [](String const & string) -> Variant<GC::Root<TrustedTypes::TrustedHTML>, GC::Root<TrustedTypes::TrustedScript>, GC::Root<TrustedTypes::TrustedScriptURL>, Utf16String> { return Utf16String::from_utf8 (string); }));
@@ -365,7 +365,7 @@ WebIDL::ExceptionOr<QualifiedName> validate_and_extract(JS::Realm& realm, Option
365365
366366// FIXME: Trusted Types integration with DOM is still under review https://github.com/whatwg/dom/pull/1268
367367// https://whatpr.org/dom/1268.html#dom-element-setattributens
368- WebIDL::ExceptionOr<void > Element::set_attribute_ns (Optional<FlyString> const & namespace_, FlyString const & qualified_name, Variant<GC::Root<TrustedTypes::TrustedHTML>, GC::Root<TrustedTypes::TrustedScript>, GC::Root<TrustedTypes::TrustedScriptURL>, Utf16String> const & value)
368+ WebIDL::ExceptionOr<void > Element::set_attribute_ns_for_bindings (Optional<FlyString> const & namespace_, FlyString const & qualified_name, Variant<GC::Root<TrustedTypes::TrustedHTML>, GC::Root<TrustedTypes::TrustedScript>, GC::Root<TrustedTypes::TrustedScriptURL>, Utf16String> const & value)
369369{
370370 // 1. Let (namespace, prefix, localName) be the result of validating and extracting namespace and qualifiedName given "element".
371371 auto extracted_qualified_name = TRY (validate_and_extract (realm (), namespace_, qualified_name, ValidationContext::Element));
@@ -421,14 +421,14 @@ void Element::set_attribute_value(FlyString const& local_name, String const& val
421421}
422422
423423// https://dom.spec.whatwg.org/#dom-element-setattributenode
424- WebIDL::ExceptionOr<GC::Ptr<Attr>> Element::set_attribute_node (Attr& attr)
424+ WebIDL::ExceptionOr<GC::Ptr<Attr>> Element::set_attribute_node_for_bindings (Attr& attr)
425425{
426426 // The setAttributeNode(attr) and setAttributeNodeNS(attr) methods steps are to return the result of setting an attribute given attr and this.
427427 return attributes ()->set_attribute (attr);
428428}
429429
430430// https://dom.spec.whatwg.org/#dom-element-setattributenodens
431- WebIDL::ExceptionOr<GC::Ptr<Attr>> Element::set_attribute_node_ns (Attr& attr)
431+ WebIDL::ExceptionOr<GC::Ptr<Attr>> Element::set_attribute_node_ns_for_bindings (Attr& attr)
432432{
433433 // The setAttributeNode(attr) and setAttributeNodeNS(attr) methods steps are to return the result of setting an attribute given attr and this.
434434 return attributes ()->set_attribute (attr);
@@ -1746,7 +1746,7 @@ i32 Element::tab_index() const
17461746// https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex
17471747void Element::set_tab_index (i32 tab_index)
17481748{
1749- MUST ( set_attribute ( HTML::AttributeNames::tabindex, String::number (tab_index) ));
1749+ set_attribute_value ( HTML::AttributeNames::tabindex, String::number (tab_index));
17501750}
17511751
17521752// https://drafts.csswg.org/cssom-view/#potentially-scrollable
@@ -2544,6 +2544,22 @@ ErrorOr<void> Element::scroll_into_view(Optional<Variant<bool, ScrollIntoViewOpt
25442544 return {};
25452545}
25462546
2547+ #define __ENUMERATE_ARIA_ATTRIBUTE (name, attribute ) \
2548+ Optional<String> Element::name () const \
2549+ { \
2550+ return get_attribute (ARIA::AttributeNames::name); \
2551+ } \
2552+ \
2553+ void Element::set_##name(Optional<String> const & value) \
2554+ { \
2555+ if (value.has_value ()) \
2556+ set_attribute_value (ARIA::AttributeNames::name, *value); \
2557+ else \
2558+ remove_attribute (ARIA::AttributeNames::name); \
2559+ }
2560+ ENUMERATE_ARIA_ATTRIBUTES
2561+ #undef __ENUMERATE_ARIA_ATTRIBUTE
2562+
25472563void Element::invalidate_style_after_attribute_change (FlyString const & attribute_name, Optional<String> const & old_value, Optional<String> const & new_value)
25482564{
25492565 Vector<CSS::InvalidationSet::Property, 1 > changed_properties;
0 commit comments