Class: Capybara::Selector::CSSBuilder Private
- Inherits:
-
Object
- Object
- Capybara::Selector::CSSBuilder
- Defined in:
- lib/capybara/selector/builders/css_builder.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Class Method Summary collapse
Class Method Details
.attribute_conditions(attributes) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/capybara/selector/builders/css_builder.rb', line 10 def attribute_conditions(attributes) attributes.map do |attribute, value| case value when XPath::Expression raise ArgumentError, "XPath expressions are not supported for the :#{attribute} filter with CSS based selectors" when Regexp Selector::RegexpDisassembler.new(value).substrings.map do |str| "[#{attribute}*='#{str}'#{' i' if value.casefold?}]" end.join when true "[#{attribute}]" when false ':not([attribute])' else if attribute == :id "##{::Capybara::Selector::CSS.escape(value)}" else "[#{attribute}='#{value}']" end end end.join end |
.class_conditions(classes) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/capybara/selector/builders/css_builder.rb', line 33 def class_conditions(classes) case classes when XPath::Expression raise ArgumentError, 'XPath expressions are not supported for the :class filter with CSS based selectors' when Regexp attribute_conditions(class: classes) else cls = Array(classes).group_by { |cl| cl.start_with?('!') && !cl.start_with?('!!!') } (cls[false].to_a.map { |cl| ".#{Capybara::Selector::CSS.escape(cl.sub(/^!!/, ''))}" } + cls[true].to_a.map { |cl| ":not(.#{Capybara::Selector::CSS.escape(cl.slice(1..-1))})" }).join end end |