From b15571fe8903b17ecbcc098f4f3ac3e357346a27 Mon Sep 17 00:00:00 2001 From: Adrian Cochrane Date: Mon, 15 Jul 2019 12:44:58 +1200 Subject: [PATCH] Add method to override CSS inheritance. --- src/Data/CSS/Style.hs | 6 +++++- stylish-haskell.cabal | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Data/CSS/Style.hs b/src/Data/CSS/Style.hs index 1eb2f41..faab3e9 100644 --- a/src/Data/CSS/Style.hs +++ b/src/Data/CSS/Style.hs @@ -53,6 +53,9 @@ cascadeProperties overrides props = fromList (props ++ overrides) class PropertyParser a where temp :: a + inherit :: a -> a + inherit = id + shorthand :: a -> Text -> [Token] -> [(Text, [Token])] shorthand self name value | Just _ <- longhand self self name value = [(name, value)] | otherwise = [] @@ -60,7 +63,8 @@ class PropertyParser a where longhand :: a -> a -> Text -> [Token] -> Maybe a cascade :: PropertyParser p => QueryableStyleSheet p -> Element -> [(Text, [Token])] -> p -> p -cascade self el overrides parent = dispatch parent parent $ toList $ cascadeRules overrides $ queryRules self el +cascade self el overrides parent = dispatch parent (inherit parent) $ + toList $ cascadeRules overrides $ queryRules self el dispatch parent child ((name, value):props) | Just child' <- longhand parent child name value = dispatch parent child' props diff --git a/stylish-haskell.cabal b/stylish-haskell.cabal index ec761b2..e22e078 100644 --- a/stylish-haskell.cabal +++ b/stylish-haskell.cabal @@ -10,7 +10,7 @@ name: stylish-haskell -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change -version: 0.3.0 +version: 0.4.0 -- A short (one-line) description of the package. synopsis: Apply CSS styles to a document tree. -- 2.30.2