Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: ea7f71a02362db633cba1c6a9c7085dd66222d87
https://github.com/WebKit/WebKit/commit/ea7f71a02362db633cba1c6a9c7085dd66222d87
Author: Ahmad Saleem <[email protected]>
Date: 2026-09-25 (Fri, 25 Sep 2026)
Changed paths:
M
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/empty-src-no-current-request-expected.txt
M Source/WebCore/html/HTMLImageElement.cpp
M Source/WebCore/loader/ImageLoader.cpp
Log Message:
-----------
Defer the error event for an empty-source lazily-loaded img until it is
connected
https://bugs.webkit.org/show_bug.cgi?id=325102
rdar://188254215
Reviewed by Chris Dumez.
This patch aligns WebKit with Gecko / Firefox.
Per the HTML Standard's "update the image data" algorithm [1], when the
selected source is null (which is the case for an img whose src is the
empty string and that does not use srcset or picture), the user agent
sets the current request's state to broken and queues an element task
to fire an error event at the element:
For an img whose lazy loading attribute is in the Lazy state, this error
task must not be observable before the "will lazy load element steps"
have a chance to run; those steps begin intersection-observing the
element, which cannot occur until the element is connected to a
document. WebCore instead scheduled the error event synchronously from
update the image data, so an img with loading="lazy" and an empty src
fired error while it was still disconnected, before it was ever inserted
into a document.
Defer the error event for the empty/whitespace selected-source case when
the element is a lazily-loadable img that is not connected. The element's
insertion steps count as a relevant mutation and re-run update the image
data (the loader still holds no image), at which point the element is
connected and the error event is queued and fired, as the specification
requires.
Because the src attribute may be set before the loading attribute enters
the Lazy state, the error may already have been scheduled while the
element was in the Eager state. On the eager-to-lazy transition of a
disconnected img that has no image, re-run update the image data so the
already-scheduled error is cancelled and deferred, keeping the observable
behavior independent of the order in which src and loading are set.
[1] https://html.spec.whatwg.org/multipage/images.html#updating-the-image-data
*
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/empty-src-no-current-request-expected.txt:
Progression
* Source/WebCore/html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::attributeChanged):
* Source/WebCore/loader/ImageLoader.cpp:
(WebCore::ImageLoader::updateFromElement):
Canonical link: https://commits.webkit.org/321900@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications