def _matchNodeAttributes?(node, attributes)
return true if attributes.nil?
raise TypeError if !attributes.is_a?(Hash)
return true if attributes.length == 0
return false if node.nodeType != ELEMENT_NODE
attributes.each do |name, value|
case name
when '*'
return catch(:match) {
node.attributes.each do |attr|
throw(:match, true) if _matchAttribute?(attr, value)
end
false
}
when Spec::Name
attr = node.attributes[name] unless node.attributes.nil?
return _matchAttribute?(attr, value)
else
raise "invalid attribute name: '#{name}'"
end
end
end