From c592ce4023fdd6877aeeb38dfbbf54790dea238f Mon Sep 17 00:00:00 2001 From: kou Date: Tue, 3 Apr 2018 15:51:08 +0000 Subject: rexml: Fix a XPath bug of name(node-set) [Bug #14600] * lib/rexml/functions.rb: Fix a bug that "name(node-set)" returns element instead of element name. * test/rexml/test_jaxen.rb: Enable more tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rexml/functions.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/rexml') diff --git a/lib/rexml/functions.rb b/lib/rexml/functions.rb index cd879fdd28..b84209619d 100644 --- a/lib/rexml/functions.rb +++ b/lib/rexml/functions.rb @@ -86,10 +86,14 @@ module REXML # Helper method. def Functions::get_namespace( node_set = nil ) if node_set == nil - yield @@context[:node] if defined? @@context[:node].namespace + yield @@context[:node] if @@context[:node].respond_to?(:namespace) else if node_set.respond_to? :each - node_set.each { |node| yield node if defined? node.namespace } + result = [] + node_set.each do |node| + result << yield(node) if node.respond_to?(:namespace) + end + result elsif node_set.respond_to? :namespace yield node_set end -- cgit v1.2.3