mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-01 03:57:15 +02: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:
committed by
Tim Ledbetter
parent
5387c923ca
commit
202c55bf28
Notes:
github-actions[bot]
2025-07-04 17:11:37 +00:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/LadybirdBrowser/ladybird/commit/202c55bf286 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5302 Reviewed-by: https://github.com/tcl3 ✅
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user