Skip to content

Commit

Permalink
prefactor: extract Searchable#get_xpath_context
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed Dec 14, 2024
1 parent 706b76d commit 3622493
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/nokogiri/xml/searchable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,19 @@ def xpath_internal(node, paths, handler, ns, binds)
end

def xpath_impl(node, path, handler, ns, binds)
ctx = XPathContext.new(node)
ctx = get_xpath_context(node)

ctx.register_namespaces(ns)
ctx.register_variables(binds)

path = path.gsub("xmlns:", " :") unless Nokogiri.uses_libxml?

ctx.evaluate(path, handler)
end

def get_xpath_context(node)
XPathContext.new(node)
end
end
end
end

0 comments on commit 3622493

Please sign in to comment.