LibWeb: Implement the :target-within
pseudo-class selector
As noted in a9620d8784
we don't currently
set the target element so this does not function, so no tests. But it
should work once we have a fleshed out Navigables implementation. :^)
This commit is contained in:
parent
3af8b491b4
commit
3d10bf3ae7
Notes:
sideshowbarker
2024-07-17 03:03:37 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/3d10bf3ae7 Pull-request: https://github.com/SerenityOS/serenity/pull/20713
2 changed files with 9 additions and 0 deletions
|
@ -113,6 +113,9 @@
|
|||
"target": {
|
||||
"argument": ""
|
||||
},
|
||||
"target-within": {
|
||||
"argument": ""
|
||||
},
|
||||
"visited": {
|
||||
"argument": ""
|
||||
},
|
||||
|
|
|
@ -446,6 +446,12 @@ static inline bool matches_pseudo_class(CSS::Selector::SimpleSelector::PseudoCla
|
|||
}
|
||||
case CSS::PseudoClass::Target:
|
||||
return element.is_target();
|
||||
case CSS::PseudoClass::TargetWithin: {
|
||||
auto* target_element = element.document().target_element();
|
||||
if (!target_element)
|
||||
return false;
|
||||
return element.is_inclusive_ancestor_of(*target_element);
|
||||
}
|
||||
case CSS::PseudoClass::Dir: {
|
||||
// "Values other than ltr and rtl are not invalid, but do not match anything."
|
||||
// - https://www.w3.org/TR/selectors-4/#the-dir-pseudo
|
||||
|
|
Loading…
Add table
Reference in a new issue