nodes named "description" are not accessible through Slop #330

Closed
ghazel opened this Issue Aug 19, 2010 · 2 comments

Comments

Projects
None yet
2 participants

ghazel commented Aug 19, 2010

doc = Nokogiri::Slop("<item><title>foo</title><description>this is the foo thing</description></item>")
p "doc.item.title:", doc.item.title
p "doc.item.description:", doc.item.description

Prints:

"doc.item.title:"
#<Nokogiri::XML::Element:0x243ba0a name="title" children=[#<Nokogiri::XML::Text:0x243b8ac "foo">]>
"doc.item.description:"
nil
Owner

tenderlove commented Oct 15, 2010

Hi! Unfortunately, we can't fix this. The reason is because Nokogiri::XML::Node responds to "description". With HTML documents, "description" returns a description of the node, where on XML documents, it returns nil.

I've added a hack for the slop visitor that lets you use an underscore if the method is already defined. So you can do this:

doc.item._description

Hope that helps!

Owner

tenderlove commented Oct 15, 2010

adding a hack for the slop decorator. closed by d9f41bf

@sglee77 sglee77 pushed a commit to sglee77/nokogiri that referenced this issue Jul 21, 2011

@tenderlove tenderlove adding a hack for the slop decorator. fixes #330 d9f41bf

@sglee77 sglee77 pushed a commit to sglee77/nokogiri that referenced this issue Jul 21, 2011

@tenderlove tenderlove Merge branch '1.4'
* 1.4:
  adding a hack for the slop decorator.  fixes #330

Conflicts:
	Manifest.txt
4cdc53b

This issue was closed.

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