You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

specificity.go 545B

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