~alcinnz/haskell-stylist

f58afc008d833a9bd70d3c4e62d8042ba0c4f851 — Adrian Cochrane 1 year, 6 months ago 9d1815a
Correct inherieance to include unmodified counters.
1 files changed, 3 insertions(+), 2 deletions(-)

M src/Data/CSS/Preprocessor/Text.hs
M src/Data/CSS/Preprocessor/Text.hs => src/Data/CSS/Preprocessor/Text.hs +3 -2
@@ 304,8 304,9 @@ t = flip StyleTree []
type Context = M.HashMap Text [([Integer], Int)]

inheritCounters :: Context -> Context -> Context
inheritCounters counterSource valueSource = M.intersectionWith cb valueSource counterSource -- indexed by name & el-path
    where cb val source = [counter | counter@(path, _) <- val, path `elem` [p | (p, _) <- source]]
inheritCounters counterSource valueSource = M.unionWith cb valueSource counterSource -- indexed by name & el-path
    where cb val source = [counter | counter@(path, _) <- val,
                            path `elem` [p | (p, _) <- source]]

instantiateCounter :: Context -> Path -> Text -> Int -> Context
instantiateCounter counters path name val = M.insertWith appendCounter name [(path, val)] counters