Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix event handler ObjectEnvironment instantiation
This works around a bug (nodejs/node#30985) which would prevent eventually migrating the global object to using a Proxy. It also prevents a global variable named "element" or "formOwner" from breaking the inner with statements.
- Loading branch information
Showing
2 changed files
with
64 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...ts/to-upstream/html/webappapis/events/event-handler-object-environment-instantiation.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!DOCTYPE html> | ||
<meta charset="UTF-8" /> | ||
<title>Inline handler correct ObjectEnvironment instantiation</title> | ||
<link rel="author" title="ExE Boss" href="https://ExE-Boss.tech" /> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/webappapis.html#getting-the-current-value-of-the-event-handler" /> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<div id="log"></div> | ||
<script> | ||
"use strict"; | ||
|
||
window.element = document.element = { | ||
get [Symbol.unscopables]() { | ||
return assert_unreached("get element[Symbol.unscopables]()"); | ||
}, | ||
onclickCalled: null | ||
}; | ||
|
||
</script> | ||
<div id="foo" onclick=' | ||
assert_equals(element, window.element, "element === window.element"); | ||
assert_equals(onclickCalled, false); | ||
onclickCalled = true; | ||
'></div> | ||
<script> | ||
"use strict"; | ||
|
||
test(() => { | ||
const foo = document.getElementById("foo"); | ||
foo.onclickCalled = false; | ||
foo.click(); | ||
assert_equals(foo.onclickCalled, true); | ||
}); | ||
|
||
</script> |