Skip to content

script: Do not clone nodes into a live document for SVG's <use> - #46261

Merged
TimvdLippe merged 1 commit into
servo:mainfrom
mrobinson:svg-live-clone
Jul 4, 2026
Merged

script: Do not clone nodes into a live document for SVG's <use>#46261
TimvdLippe merged 1 commit into
servo:mainfrom
mrobinson:svg-live-clone

Conversation

@mrobinson

@mrobinson mrobinson commented Jul 4, 2026

Copy link
Copy Markdown
Member

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.

This change also avoids cloning a node for <use> when it already exits
inside the same <svg> element as that would create duplicate ids.

Testing: This change adds a WPT crash test.
Fixes: #46250.

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>
@mrobinson
mrobinson requested a review from gterzian as a code owner July 4, 2026 08:05
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jul 4, 2026
@mrobinson

Copy link
Copy Markdown
Member Author

@Loirooriol I've added you as a co-author on this one.

@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

🤖 Opened new upstream WPT pull request (web-platform-tests/wpt#61074) with upstreamable changes.

@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

✍ Updated existing upstream WPT pull request (web-platform-tests/wpt#61074) title and body.

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Jul 4, 2026
@TimvdLippe
TimvdLippe added this pull request to the merge queue Jul 4, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jul 4, 2026
Merged via the queue into servo:main with commit 8343029 Jul 4, 2026
35 checks passed
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stack overflow via script::dom::html::htmliframeelement::HTMLIFrameElement>::continue_navigation ()

4 participants