WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
167549
Invoking generated callback should allow setting the `this` object
https://bugs.webkit.org/show_bug.cgi?id=167549
Summary
Invoking generated callback should allow setting the `this` object
Joseph Pecoraro
Reported
2017-01-28 02:28:42 PST
Summary: Invoking callback should allow setting the `this` object. Cases like IntersectionObserver, PerformanceObserver and MutationObserver. For example PerformanceObserver: <script> let observer = new PerformanceObserver(function f(list, obs) { console.log("this", this); // Expected `observer`, was `arguments.callee` }) observer.observe({entryTypes: ["mark"]}); performance.mark("mark1"); </script> The callbacks and their interface are autogenerated from WebIDL and have a handleEvent method. Seems we need a way to the `this` object in some cases. (Probably not all, requestAnimationFrame for example prolly doesn't have the same constraints). Currently this works with MutationObserver, which has a custom implementation of the callback (not generated). See JSMutationCallback. <body> <div id="my-div"></div> <script> var target = document.getElementById("my-div"); var observer = new MutationObserver(function(mutations) { console.log("this", this); // Expected `observer` but is `arguments.callee` }); observer.observe(target, {childList: true}); target.appendChild( document.createElement("span") ); </script>
Attachments
Add attachment
proposed patch, testcase, etc.
Ahmad Saleem
Comment 1
2022-09-03 06:30:00 PDT
JSFiddle -
https://jsfiddle.net/79xqnct6/
*** Chrome Canary 107 *** "this", [object PerformanceObserver] { disconnect: function disconnect() { [native code] }, observe: function observe() { [native code] }, takeRecords: function takeRecords() { [native code] } } *** Firefox Nightly 106 *** "this", [object PerformanceObserver] { disconnect: function disconnect() { [native code] }, observe: function observe() { [native code] }, takeRecords: function takeRecords() { [native code] } } *** Safari Technology Preview 152 *** "this", [object PerformanceObserver] { disconnect: function disconnect() { [native code] }, observe: function observe() { [native code] }, takeRecords: function takeRecords() { [native code] } } _________________ Is anything needed here? Thanks!
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug