class Capybara::Selector::CSS
def self.escape(str)
def self.escape(str) value = str.dup out = "".dup out << value.slice!(0...1) if value =~ /^[-_]/ out << (value[0] =~ NMSTART ? value.slice!(0...1) : escape_char(value.slice!(0...1))) out << value.gsub(/[^a-zA-Z0-9_-]/) { |c| escape_char c } out end
def self.escape_char(c)
def self.escape_char(c) c =~ %r{[ -/:-~]} ? "\\#{c}" : format("\\%06x", c.ord) end