Opened 15 years ago

Closed 15 years ago

#3745 closed defect (fixed)

scoping for function parameters is weird in IE

Reported by: bill Owned by: bill
Priority: high Milestone: 0.9
Component: Dijit Version: 0.9
Keywords: Cc:
Blocked By: Blocking:


On IE, in a declaration like

<button dojoType=... onClick="console.log('hello world');">

the parser receives onClick as type Function (rather than String like on FF). The parser essentially does


and then later the widget calls


That's all fine, but the strange thing is that references inside of onClick are resolved with scoping to this before the global namespace, so that the code below will end up calling widget.setValue() in preference to the global setValue.

<script> function setValue(){ alert('hello world'); } </script>
<button dojoType=... onClick="setValue();">

It's as though the code inside the widget is doing with(this){ this.onClick; }, even though there's no actual "with" clause. (Thanks to Mark for figuring most of this out.)

Attachments (1)

test_Button.html (8.3 KB) - added by bill 15 years ago.
test file with button (click first button)

Download all attachments as: .zip

Change History (2)

Changed 15 years ago by bill

Attachment: test_Button.html added

test file with button (click first button)

comment:1 Changed 15 years ago by bill

Resolution: fixed
Status: newclosed

(In [9640]) Fix various IE problems with parameters that are builtin function names, like onclick and onchange.


<button dojoType=dijit.form.Button onChange="foo" onClick="setValue();}>

The onChange got defined as an invalid function:

function anonymous(){ foo }

The onClick ended up calling dijit.form.Button.setValue(), rather than the global setValue().

Fixes #3745.

Note: See TracTickets for help on using tickets.