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: |
Description
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
widget.onClick=node.getAttribute("onClick");
and then later the widget calls
this.onClick();
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)
Change History (2)
Changed 15 years ago by
Attachment: | test_Button.html added |
---|
comment:1 Changed 15 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
(In [9640]) Fix various IE problems with parameters that are builtin function names, like onclick and onchange.
Example:
<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.
test file with button (click first button)