Support for using namespace-uri() with attributes.
This commit is contained in:
		
							parent
							
								
									0d41693bfc
								
							
						
					
					
						commit
						da09f1296c
					
				|  | @ -751,7 +751,7 @@ module Oga | |||
|       def on_call_namespace_uri(context, expression = nil) | ||||
|         node = function_node(context, expression) | ||||
| 
 | ||||
|         if node.is_a?(XML::Element) and node.namespace | ||||
|         if node.respond_to?(:namespace) and node.namespace | ||||
|           return node.namespace.uri | ||||
|         else | ||||
|           return '' | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ require 'spec_helper' | |||
| describe Oga::XPath::Evaluator do | ||||
|   context 'namespace-uri() function' do | ||||
|     before do | ||||
|       @document  = parse('<root xmlns:x="y"><x:a></x:a><b></b></root>') | ||||
|       @document  = parse('<root xmlns:x="y"><x:a></x:a><b x:num="10"></b></root>') | ||||
|       @evaluator = described_class.new(@document) | ||||
|     end | ||||
| 
 | ||||
|  | @ -12,6 +12,10 @@ describe Oga::XPath::Evaluator do | |||
|         @evaluator.evaluate('namespace-uri(root/x:a)').should == 'y' | ||||
|       end | ||||
| 
 | ||||
|       example 'return the namespace URI of the "num" attribute' do | ||||
|         @evaluator.evaluate('namespace-uri(root/b/@x:num)').should == 'y' | ||||
|       end | ||||
| 
 | ||||
|       example 'return an empty string when there is no namespace URI' do | ||||
|         @evaluator.evaluate('namespace-uri(root/b)').should == '' | ||||
|       end | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue