You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a feature request to match Nokogiri's default behavior of deep-copying when calling dup or clone on the parser result. This behavior is useful when working with parsed source multiple times, since re-parsing each time can get expensive.
Here's a trivial (and currently failing) test case that shows how the two parsers clone:
#!/usr/bin/env ruby
require "nokogiri"
require "oga"
require "minitest/autorun"
class CloningTest < Minitest::Test
def test_cloning_with_nokogiri
dom = Nokogiri::HTML5.parse "<html><body></body></html>"
clone = dom.clone
clone.at_xpath('/html/body[1]').content = "new"
refute_equal dom.at_xpath('/html/body[1]').content, clone.at_xpath('/html/body[1]').content
end
def test_cloning_with_oga
dom = Oga.parse_html "<html><body></body></html>"
clone = dom.clone
clone.at_xpath('/html/body[1]').inner_text = "new"
refute_equal dom.at_xpath('/html/body[1]').inner_text, clone.at_xpath('/html/body[1]').inner_text
end
end
The text was updated successfully, but these errors were encountered:
This is a feature request to match Nokogiri's default behavior of deep-copying when calling
dup
orclone
on the parser result. This behavior is useful when working with parsed source multiple times, since re-parsing each time can get expensive.Here's a trivial (and currently failing) test case that shows how the two parsers clone:
The text was updated successfully, but these errors were encountered: