Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NodeSet#search problems and NodeSet#+ is not different from NodeSet#& #119

Closed
Serabe opened this issue Aug 12, 2009 · 1 comment
Closed

Comments

@Serabe
Copy link
Contributor

Serabe commented Aug 12, 2009

Hi there:

I've been tracking down some problems with my implementation for XPath and I think it is not my problem, but yours. Let me explain. In Nokogiri::XML::NodeSet#search you can see:

each do |node|
  paths.each do |path|
    sub_set +=
      send(path =~ /^(\.\/|\/)/ ? :xpath : :css, *(paths + [ns]))
  end
end

Ok, for each node you're iterating over paths and, for each path, you're calling either the xpath or the css method of NodeSet. And guess what, both of them iterates over each node... again. You can take a look at search, xpath and css methods in Nokogiri::XML::NodeSet.

The easiest way to fix this is deleting lines 75 and 80.

Just to explain why this is happening, my implementation is based on RubyArray and I used the op_plus function in it. By the way, if you're implementation of the plus operator removes duplicates I see no difference between + and &, so I would like to know what should I do in the java impl.

@tenderlove
Copy link
Member

making NodeSet more consistent with Set, adding NodeSet#| closed by 541cbeb

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants