script: Do not clone nodes into a live document for SVG's <use> - #46261
Merged
Conversation
Cloning nodes into a live document fires their connection steps, which can do things like load `<iframe>` contents. This is not good. Instead of doing this, clone the entire SVG tree into a `DocumentFragment` so that all nodes are essentially inert. This prevents infinite recursion when combining `<use>` with `<iframe>` as `<iframe>` attachment steps trigger synchronous layouts, which in turn trigger SVG cloning and rasterization again. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Member
Author
|
@Loirooriol I've added you as a co-author on this one. |
Collaborator
|
🤖 Opened new upstream WPT pull request (web-platform-tests/wpt#61074) with upstreamable changes. |
Collaborator
|
✍ Updated existing upstream WPT pull request (web-platform-tests/wpt#61074) title and body. |
TimvdLippe
approved these changes
Jul 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cloning nodes into a live document fires their connection steps, which
can do things like load
<iframe>contents. This is not good. Insteadof doing this, clone the entire SVG tree into a
DocumentFragmentsothat all nodes are essentially inert. This prevents infinite recursion
when combining
<use>with<iframe>as<iframe>attachment stepstrigger synchronous layouts, which in turn trigger SVG cloning and
rasterization again.
This change also avoids cloning a node for
<use>when it already exitsinside the same
<svg>element as that would create duplicate ids.Testing: This change adds a WPT crash test.
Fixes: #46250.