Class: Dommy::Internal::CSSPseudoHandlers

Inherits:
BasicObject
Includes:
Kernel
Defined in:
lib/dommy/internal/css_pseudo_handlers.rb

Overview

Custom Nokogiri pseudo-class handlers so CSS selectors like ‘:disabled` / `:enabled` / `:checked` work in query_selector(_all). Nokogiri calls the method named after the pseudo-class with the current node list and expects the filtered list back. Receives raw Nokogiri nodes (not Dommy wrappers).

Instance Method Summary collapse

Instance Method Details

#checked(list) ⇒ Object



21
22
23
# File 'lib/dommy/internal/css_pseudo_handlers.rb', line 21

def checked(list)
  list.find_all { |node| node.has_attribute?("checked") }
end

#disabled(list) ⇒ Object



13
14
15
# File 'lib/dommy/internal/css_pseudo_handlers.rb', line 13

def disabled(list)
  list.find_all { |node| node.has_attribute?("disabled") }
end

#enabled(list) ⇒ Object



17
18
19
# File 'lib/dommy/internal/css_pseudo_handlers.rb', line 17

def enabled(list)
  list.find_all { |node| !node.has_attribute?("disabled") }
end