Closed afonsolage closed 1 year ago
Fixes #21
Added an weight on Selector which is based on Specificity by Mozilla.
Selector
In short terms, we compute a sum based weight for each element on rule, where:
Component
1
Class
10
Name
100
PseudoClass
In that way:
.ui-bg text
.ui-bg text:hover
#alert.ui-bg text:hover
Low weight rules are applied first so they got overwritten by high weight rules.
Fixes #21
Added an weight on
Selector
which is based on Specificity by Mozilla.In short terms, we compute a sum based weight for each element on rule, where:
Component
names, since they are more broad, just add1
;Class
names are a bit more specific, so add10
;Name
s are very specific, so add100
;PseudoClass
adds the same asClass
, so 10;In that way:
.ui-bg text
would have a total weight of 11;.ui-bg text:hover
would have a total weight of 21;#alert.ui-bg text:hover
would have a total weight of 121;Low weight rules are applied first so they got overwritten by high weight rules.