mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 02:27:19 +02:00
LibWeb/HTML: Do not run script on child removal
Matching the behaviour of the other big three browser engines, also tested by WPT, but does not appear to be explicitly specified. I also noticed when investigating that browser engines disagree about whether a child mutation should trigger script execution. For this, I've just gone with the behaviour of Webkit/Chromium of not running script.
This commit is contained in:
committed by
Jelle Raaijmakers
parent
cc6536b527
commit
27436c3971
Notes:
github-actions[bot]
2026-03-19 08:47:52 +00:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/27436c3971f Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8486 Reviewed-by: https://github.com/gmta ✅
@@ -652,6 +652,12 @@ void HTMLScriptElement::children_changed(ChildrenChangedMetadata const& metadata
|
||||
{
|
||||
Base::children_changed(metadata);
|
||||
|
||||
// AD-HOC: Avoid running script on child removal, matching the behaviour of other browsers.
|
||||
// We also do not run script on child mutation, matching the behaviour of chromium and webkit.
|
||||
// See: https://github.com/whatwg/html/issues/12279
|
||||
if (metadata.type != ChildrenChangedMetadata::Type::Inserted)
|
||||
return;
|
||||
|
||||
// 1. If the script element is not connected, then return.
|
||||
if (!is_connected())
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user