Skip to content

ref(deps): Patch zrender to clear nodes with textContent - #125290

Merged
oioki merged 2 commits into
masterfrom
oioki/ref/zrender-text-content
Sep 23, 2026
Merged

oioki merged 2 commits into
masterfrom
oioki/ref/zrender-text-content

Conversation

@oioki

@oioki oioki commented Sep 23, 2026

Copy link
Copy Markdown
Member

zrender's canvas and SVG painters clear their root and helper nodes by assigning to innerHTML. That is a Trusted Types injection sink, so every chart render and dispose is rejected on a page that sets require-trusted-types-for 'script'. Charts are the single largest source of sinks we pull in (133 occurrences across echarts/zrender), and none of them are reachable from our own code.

All seven writes assign an empty string, so textContent = '' is equivalent and clears the node the same way. The remaining innerHTML in svg-legacy/Painter.js is a read, not a write, and is left alone.

Submitted upstream as ecomfe/zrender#1167. Patching locally until it lands — upstream acceptance is not on our timeline, and charts are unusable under enforcement without it.

Verified: the 13 chart suites in static/app/components/charts pass (126 tests), and the patched files contain no remaining innerHTML writes.

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Sep 23, 2026
@oioki oioki mentioned this pull request Sep 8, 2026
zrender's canvas and SVG painters clear their root and helper nodes by assigning to innerHTML. Assigning to innerHTML is a Trusted Types injection sink, so every chart render and dispose is rejected on a page that sets `require-trusted-types-for 'script'`.

All seven writes assign an empty string, so textContent is equivalent and clears the node the same way. The remaining innerHTML in svg-legacy/Painter.js is a read, not a write, and is left alone.

Submitted upstream as ecomfe/zrender#1167. Patching locally until it lands, since charts are unusable under enforcement without it.
@oioki
oioki force-pushed the oioki/ref/zrender-text-content branch from a5d3a0f to 88868c1 Compare September 23, 2026 08:29
@oioki
oioki marked this pull request as ready for review September 23, 2026 08:53
@oioki
oioki requested a review from a team as a code owner September 23, 2026 08:53
@oioki
oioki requested a review from natemoo-re September 23, 2026 12:23
@@ -0,0 +1,83 @@
diff --git a/lib/canvas/Painter.js b/lib/canvas/Painter.js

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's include a patch message at the top so we know why we have this?

Says what the patch does, why it exists, when to drop it, and why the upstream PR cannot be used verbatim: it edits src/*.ts, while the published package resolves its module entry through index.js to lib/*.js, so the compiled output is what has to be patched.
@oioki
oioki merged commit 08a4282 into master Sep 23, 2026
77 checks passed
@oioki
oioki deleted the oioki/ref/zrender-text-content branch September 23, 2026 14:43

This branch was successfully deployed

1 active deployment
Preview — fa3ae11e Deployed Sep 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants