diff --git a/lib/oga/xpath/evaluator.rb b/lib/oga/xpath/evaluator.rb
index 27c35e2..f763922 100644
--- a/lib/oga/xpath/evaluator.rb
+++ b/lib/oga/xpath/evaluator.rb
@@ -515,9 +515,7 @@ module Oga
nodes = XML::NodeSet.new
context.each do |node|
- if node.is_a?(XML::Element) or node.is_a?(XML::Text)
- nodes << node
- end
+ nodes << node if node.is_a?(XML::Node)
end
return nodes
diff --git a/spec/oga/xpath/evaluator/type_tests/node_spec.rb b/spec/oga/xpath/evaluator/type_tests/node_spec.rb
index 180caaf..e721e31 100644
--- a/spec/oga/xpath/evaluator/type_tests/node_spec.rb
+++ b/spec/oga/xpath/evaluator/type_tests/node_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
describe Oga::XPath::Evaluator do
context 'node() tests' do
before do
- @document = parse('foo')
+ @document = parse('foo')
@evaluator = described_class.new(@document)
end
@@ -24,11 +24,19 @@ describe Oga::XPath::Evaluator do
@set = @evaluator.evaluate('a/node()')
end
- it_behaves_like :node_set, :length => 1
+ it_behaves_like :node_set, :length => 3
example 'return the node' do
@set[0].name.should == 'b'
end
+
+ example 'return the "foo" comment' do
+ @set[1].text.should == 'foo'
+ end
+
+ example 'return the "bar" CDATA tag' do
+ @set[2].text.should == 'bar'
+ end
end
context 'matching text nodes' do