WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
142954
img load event forgets img target when passed through Promise
https://bugs.webkit.org/show_bug.cgi?id=142954
Summary
img load event forgets img target when passed through Promise
Ben
Reported
2015-03-22 18:40:37 PDT
Wrapping image loading in a Promise does not work as expected. After the image load event fires event.target contains a IMG element When the promise is resolved event.target is null It can be worked around by resolving the promise with event.target rather than event Here is a demonstration
http://jsfiddle.net/8ys0dn4x/1/
Fails in Safari and webkit nightly In Firefox the code works as expected In Chrome there is also a bug, however it is slightly different in that the last promise to resolve in a group still remembers the target, but others are null Here is a variation on the demonstration
http://jsfiddle.net/d13sf3f2/5/
Attachments
Add attachment
proposed patch, testcase, etc.
Ben
Comment 1
2015-03-22 19:41:54 PDT
Minimal test case (new Promise( function( resolve ) { var i = document.createElement("IMG"); i.onload = function( event ) { console.log("onload", event.target ); // -> <img ...> resolve(event); }; i.src = "
http://i.imgur.com/waV028T.jpg
"; })).then( function( resolved_event ) { console.log( resolved_event.target ); // -> null });
Lucas Forschler
Comment 2
2019-02-06 09:19:02 PST
Mass move bugs into the DOM component.
Ahmad Saleem
Comment 3
2024-05-21 09:30:29 PDT
It seems to work for me and matching with Chrome Canary 127. Test case from
Comment 0
shows two console message across all browsers (Safari 17.5 , Chrome Canary 127 and Firefox Nightly 128).
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