From da4a58433cec8a6851115a5bd624a02ea1b77e69 Mon Sep 17 00:00:00 2001 From: Adrian Cochrane Date: Mon, 9 Sep 2019 15:55:11 +1200 Subject: [PATCH] Support multiple @document conditions (FIX) --- src/Data/CSS/Preprocessor/Conditions.hs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Data/CSS/Preprocessor/Conditions.hs b/src/Data/CSS/Preprocessor/Conditions.hs index a30bfbb..e1f0a43 100644 --- a/src/Data/CSS/Preprocessor/Conditions.hs +++ b/src/Data/CSS/Preprocessor/Conditions.hs @@ -27,18 +27,22 @@ instance StyleSheet ConditionalStyles where addRule self rule = self {inner = addRule (inner self) rule} addAtRule self "document" (Comma:toks) = addAtRule self "document" toks - addAtRule self "document" (Url match:toks) | unpack match == hostUrlS self = - parseAtBlock self toks - addAtRule self "document" (Function "url-prefix":String match:RightParen:toks) = + addAtRule self "document" (Url match:toks) + | unpack match == hostUrlS self = parseAtBlock self toks + | otherwise = addAtRule self "document" toks + addAtRule self "document" (Function "url-prefix":String match:RightParen:toks) | unpack match `isPrefixOf` hostUrlS self = parseAtBlock self toks + | otherwise = addAtRule self "document" toks addAtRule self "document" (Function "domain":String match:RightParen:toks) | unpack match == domain || ('.':unpack match) `isSuffixOf` domain = parseAtBlock self toks + | otherwise = addAtRule self "document" toks where domain | Just auth <- uriAuthority $ hostURL self = uriRegName auth | otherwise = "" addAtRule self "document" (Function "media-document":String match:RightParen:toks) = | unpack match == mediaDocument self = parseAtBlock self toks + | otherwise = addAtRule self "document" toks -- TODO Support regexp() conditions, requires new dependency addAtRule self "document" tokens = (self, skipAtRule tokens) -- 2.30.2