1 package cascadia 2 3 // Specificity is the CSS specificity as defined in 4 // https://www.w3.org/TR/selectors/#specificity-rules 5 // with the convention Specificity = [A,B,C]. 6 type Specificity [3]int 7 8 // returns `true` if s < other (strictly), false otherwise 9 func (s Specificity) Less(other Specificity) bool { 10 for i := range s { 11 if s[i] < other[i] { 12 return true 13 } 14 if s[i] > other[i] { 15 return false 16 } 17 } 18 return false 19 } 20 21 func (s Specificity) Add(other Specificity) Specificity { 22 for i, sp := range other { 23 s[i] += sp 24 } 25 return s 26 } 27