@@ 1,6 1,6 @@
{-# LANGUAGE OverloadedStrings #-}
module Data.CSS.Style.Importance (
- splitProperties, ImportanceSplitter(..)
+ ImportanceSplitter(..)
) where
import Data.CSS.Syntax.Tokens
@@ 15,15 15,18 @@ splitProperties (prop@(name, value):rest)
where (unimportant, important) = splitProperties rest
splitProperties [] = ([], [])
+--- NOTE: Prorities are defined with lower numbers being more important,
+--- so negate to be consistant with other priority sources.
+--- This API decision started out being accidental, but I find it more intuitive.
data ImportanceSplitter a = ImportanceSplitter a
instance RuleStore inner => RuleStore (ImportanceSplitter inner) where
new = ImportanceSplitter new
addStyleRule (ImportanceSplitter self) priority rule =
ImportanceSplitter $ addStyleRule (
- addStyleRule self (negate priority) $ buildRule important
- ) priority $ buildRule unimportant
+ addStyleRule self (negate priority) $ buildRule unimportant
+ ) priority $ buildRule important
where
- (important, unimportant) = splitProperties properties
+ (unimportant, important) = splitProperties properties
(StyleRule selector properties) = inner rule
buildRule properties = rule {inner = StyleRule selector properties}
lookupRules (ImportanceSplitter self) el = lookupRules self el