Method: Nokogiri::CSS::XPathVisitor#visit_element_name

Defined in:
lib/nokogiri/css/xpath_visitor.rb

#visit_element_name(node) ⇒ Object



245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/nokogiri/css/xpath_visitor.rb', line 245

def visit_element_name(node)
  if @doctype == DoctypeConfig::HTML5 && html5_element_name_needs_namespace_handling(node)
    # HTML5 has namespaces that should be ignored in CSS queries
    # https://github.com/sparklemotion/nokogiri/issues/2376
    if @builtins == BuiltinsConfig::ALWAYS || (@builtins == BuiltinsConfig::OPTIMAL && Nokogiri.uses_libxml?)
      if WILDCARD_NAMESPACES
        "*:#{node.value.first}"
      else
        "*[nokogiri-builtin:local-name-is('#{node.value.first}')]"
      end
    else
      "*[local-name()='#{node.value.first}']"
    end
  else
    node.value.first
  end
end