Ticket #6772 (closed defect: fixed)

Opened 7 months ago

Last modified 5 months ago

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

Changed 7 months ago by bill

  • owner changed from anonymous to sjmiles
  • component changed from Core to HTML

Changed 5 months ago by bill

  • milestone set to tbd

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

Changed 5 months 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.

Changed 5 months ago by bill

  • owner changed from sjmiles to bill
  • status changed from new to assigned
  • milestone changed from tbd to 1.2

Yah, I'll do it.

Changed 5 months ago by bill

  • status changed from assigned to closed
  • resolution set to fixed

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

Note: See TracTickets for help on using tickets.