From e8b4e6b726df97dc542752bf1f67f2e039229f5d Mon Sep 17 00:00:00 2001 From: Thilo Molitor Date: Mon, 7 Aug 2023 05:12:14 +0200 Subject: [PATCH] Implement :not() pseudo selector This may be a dirty hack, but it seems to work well. --- src/Css/Stylesheet.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Css/Stylesheet.php b/src/Css/Stylesheet.php index 852fc5e16..f61ee733f 100644 --- a/src/Css/Stylesheet.php +++ b/src/Css/Stylesheet.php @@ -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":