Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Test for callback context #435

Merged
merged 1 commit into from

2 participants

@iangreenleaf

Old-style inline callbacks are executing in the context of the window, rather than of the element that triggered the event. This causes problems when we have a callback like:

onclick="doSomething(this)"

I got as far as writing a failing test, but then I looked at the Contextify stuff and realized I wasn't sure what was going on, so I didn't code up a fix. I hope this is enough to help.

@tmpvar
Owner

yeah, this helps. We'll need to fix before I can land this though

@tmpvar tmpvar merged commit 04f1b2c into tmpvar:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 11, 2012
  1. @iangreenleaf
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 1 deletion.
  1. +7 −1 test/jsdom/index.js
View
8 test/jsdom/index.js
@@ -1062,7 +1062,8 @@ document.write("<SCR"+"IPT TYPE=\'text/javascript\' SRC=\'...\'><\/SCR"+"IPT>");
"<head></head>" +
"<body>" +
" <div onclick='window.divClicked = true;'" +
- " onmouseover='window.divMousedOver = true;'>" +
+ " onmouseover='window.divMousedOver = true;'" +
+ " onmouseout='window.divCalledFrom = this.tagName;'>" +
" <a></a>" +
" </div>" +
"</body>" +
@@ -1084,6 +1085,11 @@ document.write("<SCR"+"IPT TYPE=\'text/javascript\' SRC=\'...\'><\/SCR"+"IPT>");
div.dispatchEvent(mouseOver);
test.equal(window.divMousedOver, true);
+ var mouseOut = doc.createEvent('MouseEvents');
+ mouseOut.initMouseEvent('mouseout', false, false);
+ div.dispatchEvent(mouseOut);
+ test.equal(window.divMousedCalledFrom, "DIV");
+
test.done();
},
Something went wrong with that request. Please try again.