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 Aug 7, 2023
1 parent 87bea32 commit e8b4e6b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Css/Stylesheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,20 @@ 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) != '//*[')
{
error_log("unsupported dompdf css subquery in :not() pseudoclass: $subquery");
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 e8b4e6b

Please sign in to comment.