Class: Capybara::Selector::CSS
Relationships & Source Files | |
Namespace Children | |
Classes:
| |
Inherits: | Object |
Defined in: | lib/capybara/selector/css.rb |
Constant Summary
-
ESCAPE =
# File 'lib/capybara/selector/css.rb', line 29/#{UNICODE}|\\[ -~#{S}]/
-
H =
# File 'lib/capybara/selector/css.rb', line 26/[0-9a-fA-F]/
-
NMSTART =
# File 'lib/capybara/selector/css.rb', line 30/[_a-zA-Z]|#{NONASCII}|#{ESCAPE}/
-
NONASCII =
# File 'lib/capybara/selector/css.rb', line 28/[#{S}]/
-
S =
# File 'lib/capybara/selector/css.rb', line 25'\u{80}-\u{D7FF}\u{E000}-\u{FFFD}\u{10000}-\u{10FFFF}'
-
UNICODE =
# File 'lib/capybara/selector/css.rb', line 27/\\#{H}{1,6}[ \t\r\n\f]?/
Class Method Summary
Class Method Details
.escape(str)
[ GitHub ]# File 'lib/capybara/selector/css.rb', line 8
def self.escape(str) value = str.dup out = +'' out << value.slice!(0...1) if value.match?(/^[-_]/) out << (value[0].match?(NMSTART) ? value.slice!(0...1) : escape_char(value.slice!(0...1))) out << value.gsub(/[^a-zA-Z0-9_-]/) { |char| escape_char char } out end
.escape_char(char)
[ GitHub ]# File 'lib/capybara/selector/css.rb', line 17
def self.escape_char(char) char.match?(%r{[ -/:-~]}) ? "\\#{char}" : format('\\%06<hex>x', hex: char.ord) end