Skip to content

Commit

Permalink
Implement :not() pseudo selector
Browse files Browse the repository at this point in the history
This may be a dirty hack, but it seems to work well.
  • Loading branch information
tmolitor-stud-tu committed Sep 7, 2023
1 parent 87bea32 commit 4c48b21
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Css/Stylesheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,18 @@ protected function selectorToXpath(string $selector, bool $firstPass = false): ?
$query .= "[" . implode(" or ", $elements) . "]";
break;

case "not":
$p = $i + 1;
$length = strpos($selector, ")", $i) - $p;
$i += $length + 1;
$matchList = trim(mb_substr($selector, $p, $length));
$subquery = $this->selectorToXpath($matchList, true)['query'];
if(substr($subquery, 0, 4) != '//*[') {
return null; //not supported
}
$query .= "[not(".substr($subquery, 4, -1).")]";
break;

// https://www.w3.org/TR/selectors-3/#UIstates
case "disabled":
case "checked":
Expand Down

0 comments on commit 4c48b21

Please sign in to comment.