@@ 1,5 1,6 @@
module Stylish.Style.Selector(
-
+ QueryableStyleSheet(..), queryableStyleSheet,
+ queryRules
) where
import Stylish.Style.Selector.Index
@@ 8,6 9,8 @@ import Stylish.Style.Selector.Specificity
import Stylish.Style.Selector.Importance
import Stylish.Style.Selector.Common
+import Stylish.Parse (StyleSheet(..))
+
ruleStore = ImportanceSplitter $ OrderedRuleStore (InterpretedRuleStore styleIndex) 0
data QueryableStyleSheet store = QueryableStyleSheet {
@@ 16,3 19,10 @@ data QueryableStyleSheet store = QueryableStyleSheet {
}
queryableStyleSheet = QueryableStyleSheet {store = ruleStore, priority = 0}
+
+instance RuleStore s => StyleSheet (QueryableStyleSheet s) where
+ addRule self@(QueryableStyleSheet store priority) rule = self {
+ store = addStyleRule store priority $ styleRule' rule
+ }
+
+queryRules (QueryableStyleSheet store _) el = lookupRules store el