Skip to content

Chrome/Edge clears pending error event if img.src changed before it fired #1872

@EdgarChen

Description

@EdgarChen

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions