Ticket #6772 (closed defect: fixed)
dojo.hasAttr busts when node doesn't have the getAttributeNode function
| Reported by: | ptwobrussell | Owned by: | bill |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.2 |
| Component: | HTML | Version: | 1.1.0 |
| Severity: | normal | Keywords: | |
| Cc: | ptwobrussell@… |
Description
Since dojo.attr uses dojo.hasAttr this issue also affects it.
Test case is this (as of the nightly):
<html>
<head>
<title></title>
<script
type="text/javascript"
src="http://o.aolcdn.com/dojo/1.1/dojo/dojo.xd.js"
djConfig="isDebug:true">
</script>
<script type="text/javascript">
dojo.addOnLoad(function() {
//busts on FF (maybe elsewhere too)
//because the nextSibling is " " and does not have getAttributeNode
//would have expected false as the response
console.log(dojo.hasAttr(dojo.byId("foo").nextSibling, "blah"));
});
</script>
</head>
<body>
<span id="foo">foo</span> <span>bar</span>
</body>
</html>
Maybe the fix is to simply make this change to the dojo.hasAttr function:
var attr = d.byId(node).getAttributeNode(_fixAttrName(name));
=>
var attr = d.byId(node).getAttributeNode ? d.byId.getAttributeNode(_fixAttrName(name)) : false;
I guess this is a corner case. I discovered the issue while having to walk part of the DOM and test some attributes on nodes.
Change History
Note: See
TracTickets for help on using
tickets.