LibWeb: Give Element a CustomStateSet, exposed by ElementInternals

This commit is contained in:
Sam Atkins 2025-07-04 14:03:44 +01:00 committed by Tim Ledbetter
commit b6ffea8990
Notes: github-actions[bot] 2025-07-04 17:11:47 +00:00
10 changed files with 209 additions and 1 deletions

View file

@ -208,6 +208,13 @@ WebIDL::ExceptionOr<GC::Ptr<DOM::NodeList>> ElementInternals::labels()
return WebIDL::NotSupportedError::create(realm(), "FIXME: ElementInternals::labels()"_string);
}
// https://html.spec.whatwg.org/multipage/custom-elements.html#dom-elementinternals-states
GC::Ptr<CustomStateSet> ElementInternals::states()
{
// The states getter steps are to return this's target element's states set.
return m_target_element->ensure_custom_state_set();
}
void ElementInternals::initialize(JS::Realm& realm)
{
WEB_SET_PROTOTYPE_FOR_INTERFACE(ElementInternals);

View file

@ -57,6 +57,7 @@ public:
WebIDL::ExceptionOr<bool> report_validity() const;
WebIDL::ExceptionOr<GC::Ptr<DOM::NodeList>> labels();
GC::Ptr<CustomStateSet> states();
private:
explicit ElementInternals(JS::Realm&, HTMLElement& target_element);

View file

@ -1,4 +1,5 @@
#import <DOM/ShadowRoot.idl>
#import <HTML/CustomElements/CustomStateSet.idl>
// https://html.spec.whatwg.org/multipage/custom-elements.html#elementinternals
[Exposed=Window]
@ -24,7 +25,7 @@ interface ElementInternals {
readonly attribute NodeList labels;
// Custom state pseudo-class
[FIXME, SameObject] readonly attribute CustomStateSet states;
[SameObject] readonly attribute CustomStateSet states;
};
// Accessibility semantics