Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 819be32677e2ec636a78c9d4955492d36abdad33
      
https://github.com/WebKit/WebKit/commit/819be32677e2ec636a78c9d4955492d36abdad33
  Author: Ahmad Saleem <[email protected]>
  Date:   2026-10-09 (Fri, 09 Oct 2026)

  Changed paths:
    A 
LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/fetch-src/empty-set-while-connected-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/fetch-src/empty-set-while-connected.html
    M Source/WebCore/dom/ScriptElement.cpp
    M Source/WebCore/svg/SVGScriptElement.cpp

  Log Message:
  -----------
  Setting src to the empty string on a connected script element does not fire 
an error event
https://bugs.webkit.org/show_bug.cgi?id=326652
rdar://189385352

Reviewed by Chris Dumez.

This patch aligns WebKit with Gecko / Firefox.

The script element's attribute change steps [1] say:

    "If localName is src, value is not null, and element is connected, then
    run the script HTML element post-connection steps, given element."

ScriptElement::handleSourceAttribute() returned early when the value was
empty rather than null, so setting src to "" on a connected script element
that had not yet started never prepared it, and the error event required by
"If src is the empty string, then queue an element task on the DOM
manipulation task source given el to fire an event named error at el, and
return." was never fired.

Check isNull() instead. SVGScriptElement passes href(), which can be the
empty string when the attribute is removed, so keep its existing behavior by
skipping the call for an empty href.

[1] 
https://html.spec.whatwg.org/multipage/scripting.html#script-processing-model

Test: 
imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/fetch-src/empty-set-while-connected.html

* 
LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/fetch-src/empty-set-while-connected-expected.txt:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/fetch-src/empty-set-while-connected.html:
 Added.
* Source/WebCore/dom/ScriptElement.cpp:
(WebCore::ScriptElement::handleSourceAttribute):
* Source/WebCore/svg/SVGScriptElement.cpp:
(WebCore::SVGScriptElement::svgAttributeChanged):

Canonical link: https://commits.webkit.org/323200@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to