Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#9596 closed defect (fixed)

dojo._isButtonTag throwing exception

Reported by: Douglas Hays Owned by: sjmiles
Priority: high Milestone: 1.4
Component: Core Version: 1.3.2
Keywords: Cc: James Burke
Blocked By: Blocking:

Description (last modified by Douglas Hays)

Calling dojo.marginBox(node, {}) with an INPUT node having no explicit type will cause an exception thrown in _isButtonTag since getAttribute("type") returns null on Firefox and Safari.

<HTML>
<HEAD>
        <SCRIPT type="text/javascript" djConfig="parseOnLoad:false, isDebug:true" src="http://o.aolcdn.com/dojo/1.3.1/dojo/dojo.xd.js"></SCRIPT>
</HEAD>
<BODY>
<INPUT id="textbox" size="60" value="testing...">
<SCRIPT type="text/javascript">
        var textbox = dojo.byId('textbox');
        try{
                dojo.marginBox(textbox,{})
                textbox.value = 'No error';
        }catch(e){ textbox.value = e.message; }
</SCRIPT>
</BODY>
</HTML>

The fix to _isButtonTag is simple:

(node.getAttribute("type")||'')

Change History (7)

comment:1 Changed 10 years ago by Douglas Hays

Cc: James Burke added
Owner: changed from anonymous to sjmiles

original code added in [14386]

comment:2 Changed 10 years ago by Douglas Hays

Description: modified (diff)

comment:3 Changed 10 years ago by James Burke

Is an input without an explicit type even valid? Seems like that is just bad markup?

comment:4 Changed 10 years ago by Douglas Hays

From the HTML spec http://www.w3.org/TR/html401/interact/forms.html#h-17.4:
type = text|password|checkbox|radio|submit|reset|file|hidden|image|button
This attribute specifies the type of control to create. The default value for this attribute is "text".

comment:5 Changed 10 years ago by James Burke

Ah ok, then the (node.getAttribute("type")
) fix seems fine to do. Feel free to commit the change.

comment:6 Changed 10 years ago by Douglas Hays

Resolution: fixed
Status: newclosed

(In [19079]) Fixes #9596 !strict. Add check in _isButtonTag for null returned from getAttribute("type") since INPUT tags can default to type="text" when not explicitly specified.

comment:7 Changed 10 years ago by bill

Milestone: tbd1.4
Note: See TracTickets for help on using tickets.