sparklemotion/nokogiri — pull request #1040 by ender672 (2014-02-02 22:47:44+00:00)
Title: Allow Nokogiri::XML::Node#parse from unparented non-element nodes.

Giving this changeset a chance to be reviewed before committing.

@flavorjones - You looked at this ticket at one point. Does this solution look reasonable?

To see what libxml2 is doing here, look at parser.c:xmlParseInNodeContext(). Note how it traverses up the tree in search of an XML_ELEMENT_NODE or an XML_DOCUMENT_NODE.

The solution here is to detect that scenario and to use the document node for parsing context instead.

The problem only occurs with libxml2, and not in jruby. I've applied the solution to both since it doesn't seem to hurt.

Fixes #407