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

Node#> operator does not work in a DocumentFragment #1857

Closed
flavorjones opened this issue Jan 8, 2019 · 0 comments · Fixed by #2395
Closed

Node#> operator does not work in a DocumentFragment #1857

flavorjones opened this issue Jan 8, 2019 · 0 comments · Fixed by #2395

Comments

@flavorjones
Copy link
Member

Originally reported on the mailing list by @MaxLustig and at #1853 which was self-closed.

Failing example:

#! /usr/bin/env ruby

require 'nokogiri'

html = <<-EOHTML
    <div class="section header" id=1>
      <div class="subsection header">sub 1</div>
      <div class="subsection header">sub 2</div>
    </div>
    <div class="section header" id=2>
      <div class="subsection header">sub 3</div>
      <div class="subsection header">sub 4</div>
    </div>
EOHTML

doc = Nokogiri::HTML.fragment html

parent = doc.at_css("body")

x = parent > ".header"
# /home/flavorjones/foo.rb:22:in `<main>': undefined method `>' for nil:NilClass (NoMethodError)

We should move the definition of Node#> into Searchable and make sure it works for DocumentFragment. I'll further note that that implementation might be fraught because of the well-documented xpath-on-root-nodes issues (see #572), but this is essentially a failing test that we need to make work at some point.

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

Successfully merging a pull request may close this issue.

1 participant