Opened 13 years ago

Closed 12 years ago

#6772 closed defect (fixed)

dojo.hasAttr busts when node doesn't have the getAttributeNode function

Reported by: ptwobrussell Owned by: bill
Priority: high Milestone: 1.2
Component: HTML Version: 1.1.0
Keywords: Cc: [email protected]
Blocked By: Blocking:


Since dojo.attr uses dojo.hasAttr this issue also affects it.

Test case is this (as of the nightly):


        <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"));
        <span id="foo">foo</span> <span>bar</span>

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 (5)

comment:1 Changed 13 years ago by bill

Component: CoreHTML
Owner: changed from anonymous to sjmiles

comment:2 Changed 12 years ago by bill

Milestone: tbd

mark all (open) tickets w/blank milestones to be "tbd"; their milestones need to be set to a version number or to "future"

comment:3 Changed 12 years ago by ptwobrussell

Can someone please apply this patch for 1.2? I ran into this same problem again last night while trying to process an xml document with dojo.query. Unless I'm missing something, the fix is trivial.

comment:4 Changed 12 years ago by bill

Milestone: tbd1.2
Owner: changed from sjmiles to bill
Status: newassigned

Yah, I'll do it.

comment:5 Changed 12 years ago by bill

Resolution: fixed
Status: assignedclosed

(In [14476]) Fixes #6772: dojo.hasAttr busts when node doesn't have the getAttributeNode function !strict

Note: See TracTickets for help on using tickets.