mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-06 16:19:23 +00:00
LibWeb/CSS: Implement the :state(foo)
pseudo-class
This matches custom elements that have `foo` in their custom states set. The 2 test failures here are because we don't support `::part()` yet.
This commit is contained in:
parent
5387c923ca
commit
202c55bf28
Notes:
github-actions[bot]
2025-07-04 17:11:37 +00:00
Author: https://github.com/AtkinsSJ
Commit: 202c55bf28
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5302
Reviewed-by: https://github.com/tcl3 ✅
12 changed files with 503 additions and 2 deletions
|
@ -15,6 +15,7 @@
|
|||
#include <LibWeb/DOM/NamedNodeMap.h>
|
||||
#include <LibWeb/DOM/Text.h>
|
||||
#include <LibWeb/HTML/AttributeNames.h>
|
||||
#include <LibWeb/HTML/CustomElements/CustomStateSet.h>
|
||||
#include <LibWeb/HTML/HTMLAnchorElement.h>
|
||||
#include <LibWeb/HTML/HTMLDetailsElement.h>
|
||||
#include <LibWeb/HTML/HTMLDialogElement.h>
|
||||
|
@ -1059,6 +1060,15 @@ static inline bool matches_pseudo_class(CSS::Selector::SimpleSelector::PseudoCla
|
|||
|
||||
return false;
|
||||
}
|
||||
case CSS::PseudoClass::State: {
|
||||
// https://html.spec.whatwg.org/multipage/semantics-other.html#selector-custom
|
||||
// The :state(identifier) pseudo-class must match all custom elements whose states set's set entries contains identifier.
|
||||
if (!element.is_custom())
|
||||
return false;
|
||||
if (auto* custom_state_set = element.custom_state_set())
|
||||
return custom_state_set->has_state(pseudo_class.ident->string_value);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue