diff options
author | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-04 06:53:57 +0000 |
---|---|---|
committer | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-04 06:53:57 +0000 |
commit | 65571d54185eb0c54f41d06f82e0db2ca363ff55 (patch) | |
tree | 7d536cdc7acd7f6faac2b0e84fd75a1bc8acba2c /lib/rexml | |
parent | c2dd489fd2f6284d0bd0ccdcc38c454a10ade62f (diff) | |
download | ruby-65571d54185eb0c54f41d06f82e0db2ca363ff55.tar.gz |
rexml: Fix a XPath bug of /child::node()
[Bug #14600]
* lib/rexml/xpath_parser.rb: Fix a bug that "/child::node()" returns
XML declaration and text nodes out of root element.
* test/rexml/test_jaxen.rb: Enable more tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63088 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rexml')
-rw-r--r-- | lib/rexml/xpath_parser.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/rexml/xpath_parser.rb b/lib/rexml/xpath_parser.rb index f663215b07..a94ad91ea1 100644 --- a/lib/rexml/xpath_parser.rb +++ b/lib/rexml/xpath_parser.rb @@ -212,7 +212,19 @@ module REXML nodeset.each do |node| nt = node.node_type # trace(:child, nt, node) - new_nodeset += node.children if nt == :element or nt == :document + case nt + when :element + new_nodeset.concat(node.children) + when :document + node.children.each do |child| + case child + when XMLDecl, Text + # ignore + else + new_nodeset << child + end + end + end end nodeset = new_nodeset node_types = ELEMENTS |