Class: Dommy::Internal::SelectorAST::ComplexSelector
- Inherits:
-
Struct
- Object
- Struct
- Dommy::Internal::SelectorAST::ComplexSelector
- Defined in:
- lib/dommy/internal/selector_ast.rb
Instance Attribute Summary collapse
-
#parts ⇒ Object
Returns the value of attribute parts.
Instance Method Summary collapse
- #pseudo_element ⇒ Object
- #pseudo_element? ⇒ Boolean
- #rightmost ⇒ Object
- #specificity ⇒ Object
- #without_pseudo_element ⇒ Object
Instance Attribute Details
#parts ⇒ Object
Returns the value of attribute parts
29 30 31 |
# File 'lib/dommy/internal/selector_ast.rb', line 29 def parts @parts end |
Instance Method Details
#pseudo_element ⇒ Object
32 33 34 |
# File 'lib/dommy/internal/selector_ast.rb', line 32 def pseudo_element rightmost&.pseudo_element end |
#pseudo_element? ⇒ Boolean
36 37 38 |
# File 'lib/dommy/internal/selector_ast.rb', line 36 def pseudo_element? !pseudo_element.nil? end |
#rightmost ⇒ Object
30 |
# File 'lib/dommy/internal/selector_ast.rb', line 30 def rightmost = parts.last&.compound |
#specificity ⇒ Object
49 50 51 |
# File 'lib/dommy/internal/selector_ast.rb', line 49 def specificity parts.reduce(ZERO) { |sum, part| sum + part.compound.specificity } end |
#without_pseudo_element ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/dommy/internal/selector_ast.rb', line 40 def without_pseudo_element return self unless pseudo_element? duped = parts.map { |part| Part.new(part.combinator, part.compound) } last = duped.last last.compound = last.compound.without_pseudo_element self.class.new(duped) end |