Skip to content

Commit

Permalink
Fixes issue#1299. Adds local name check in key? method
Browse files Browse the repository at this point in the history
  • Loading branch information
yokolet committed Jun 10, 2015
1 parent 7db41b6 commit e1b5e34
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ext/java/nokogiri/XmlNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,18 @@ public IRubyObject key_p(ThreadContext context, IRubyObject rbkey) {
if (node instanceof Element) {
String key = rubyStringToString(rbkey);
Element element = (Element) node;
return context.getRuntime().newBoolean(element.hasAttribute(key));
if (element.hasAttribute(key)) {
return context.getRuntime().getTrue();
} else {
NamedNodeMap namedNodeMap = element.getAttributes();
for (int i=0; i<namedNodeMap.getLength(); i++) {
Node n = namedNodeMap.item(i);
if (key.equals(n.getLocalName())) {
return context.getRuntime().getTrue();
}
}
}
return context.getRuntime().getFalse();
} else {
return context.getRuntime().getNil();
}
Expand Down

0 comments on commit e1b5e34

Please sign in to comment.