-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Chrome/Edge clears pending error event if img.src changed before it fired #1872
Copy link
Copy link
Open
Labels
Description
Chrome/Edge seems clear pending error event if img.src changed before it fired.
Example 1:
var image1 = new Image();
var image2 = new Image();
image1.src = '';
image2.src = '';
image1.onerror = function() {
console.log('image1.onerror');
image2.src = 'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="96" height="96"><path d="M10,10L32,90L90,32z" fill="lightgreen"/></svg>';
};
image2.onerror = function() {
console.log('image2.onerror');
};Result of Chrome and Edge:
Image2's error event isn't fired.
Example 2:
var image1 = new Image();
var image2 = new Image();
image1.src = '';
image2.src = '';
image1.onerror = function() {
console.log('image1.onerror');
image2.src = '';
};
image2.onerror = function() {
console.log('image2.onerror');
};Result of Chrome and Edge:
Image2's error event is only fired once.
This behavior (clear pending error event) isn't documented in the spec. But some sites seems rely on this behavior, e.g. https://www.bing.com/mapspreview [1]. Does this behavior is what we expect?
[1] Please also see https://bugzilla.mozilla.org/show_bug.cgi?id=1308069
Reactions are currently unavailable