@@ 1,13 0,0 @@
-# Functional psuedoclasses
-These would mostly need to be added to the interpretor.
-
-* [x] :not() -- TODO apply specificity
-* [x] :dir()
-* [x] :is() -- TODO apply specificity
-* [x] :lang()
-* [x] :nth-child()
-* [ ] :nth-last-child()
-* [x] :nth-of-type()
-* [ ] :nth-last-child()
-* [x] :where()
-* etc
@@ 16,11 16,14 @@ computeSpecificity "" (Child upSel sel) = computeSpecificity "" upSel `add` comp
computeSpecificity "" (Descendant upSel sel) = computeSpecificity "" upSel `add` computeSpecificity' sel
computeSpecificity "" (Adjacent upSel sel) = computeSpecificity "" upSel `add` computeSpecificity' sel
computeSpecificity "" (Sibling upSel sel) = computeSpecificity "" upSel `add` computeSpecificity' sel
-computeSpecificity _ _ = (0, 0, 1) -- psuedoelements count as a tag.
+computeSpecificity _ sel = computeSpecificity "" sel `add` (0, 0, 1)
computeSpecificity' :: [SimpleSelector] -> Vec
computeSpecificity' (Tag _:sel) = computeSpecificity' sel `add` (0, 0, 1)
computeSpecificity' (Class _:sel) = computeSpecificity' sel `add` (0, 1, 0)
+computeSpecificity' (Psuedoclass c args:sel)
+ | c `elem` ["not", "is"], (sels, []) <- parseSelectors args =
+ computeSpecificity' sel `add` maximum (map (computeSpecificity "") sels)
computeSpecificity' (Psuedoclass _ _:sel) = computeSpecificity' sel `add` (0, 1, 0)
computeSpecificity' (Property _ _:sel) = computeSpecificity' sel `add` (0, 1, 0)
computeSpecificity' (Id _:sel) = computeSpecificity' sel `add` (1, 0, 0)