Hi,
I managed to express constraints of CSS selectors in types, so if CSS class applied to a tag that doesn’t have a proper context formed by ancestors and/or siblings of the tag, then a compilation error is produced.
E.g. for rule
.a > .b { }
and the DOM snippet where prerequisites for class b is not satisfied:
div_ </ div_ .= b
<div>
<div class="b">
</div>
</div>
Error: parent tag doesn’t have a class.
[([B, C "a"], [], [])]
Another case for siblings
.a + .b { }
div_ </ div_ </ div_ .= b
[([B], [], [[ [B], [C "a"]]])]
As far as I understand, Scala has support for GADTs and can generate/execute code at compilation. So I am curious about the feasibility of replicating such library in Scala.
Tag type has just 9 parameters responsible for tracking CSS and DOM interplay
data E
model
action
(en :: Symbol)
(es :: ElementStructure)
(re :: Maybe Root)
(ei :: Maybe Symbol)
(atrs :: [Symbol])
(knownIds :: KnownIDS)
(cls :: [Symbol])
(l :: [[[Seg]]])
(children :: [[SubSeg]])