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

CSS query fails for empty element_children in JRuby #1901

Closed
orhantoy opened this issue Apr 30, 2019 · 5 comments
Closed

CSS query fails for empty element_children in JRuby #1901

orhantoy opened this issue Apr 30, 2019 · 5 comments

Comments

@orhantoy
Copy link
Contributor

orhantoy commented Apr 30, 2019

Describe the bug

If the node set returned from Nokogiri::XML::Node#element_children is empty, querying it with .css raises an exception in JRuby. For MRI this works as expected by returning an empty node set.

To Reproduce

MRI 👍

$ RBENV_VERSION=2.5.3 ruby -I lib -r nokogiri -e "puts Nokogiri::XML('<root><row></row></root>').at_css('row').element_children.css('column').inspect"
[]

JRuby 👎

$ RBENV_VERSION=jruby-9.2.5.0 ruby -I lib -r nokogiri -e "puts Nokogiri::XML('<root><row></row></root>').at_css('row').element_children.css('column').inspect"
NoMethodError: undefined method `root' for nil:NilClass
  extract_params at [...]/nokogiri/lib/nokogiri/xml/searchable.rb:224
             css at [...]/nokogiri/lib/nokogiri/xml/node_set.rb:80
          <main> at -e:1

Expected behavior

I would expect the JRuby variant not to blow up and instead return an empty node set as with MRI.

@flavorjones
Copy link
Member

Thanks for reporting this! I'll take a look as soon as I can.

@flavorjones
Copy link
Member

@orhantoy Sorry for the delay on this -- I've not been able to work very much on OSS the past six months or so. Hopefully that'll be changing shortly.

In any case, this is a note for myself from our email thread -- which is to remember offer to pair with you when I do get to this.

@orhantoy
Copy link
Contributor Author

@flavorjones All good, welcome back ✌️

If you get the time it would be helpful to pair on this as I recall having some trouble debugging the issue.

@flavorjones
Copy link
Member

This was fixed in v1.11.0, I think as part of the node-set overhaul by @kares

@orhantoy
Copy link
Contributor Author

orhantoy commented Jul 2, 2024

Thank you, @kares

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

No branches or pull requests

2 participants