Skip to content

fix: use textContent instead of innerHTML to clear elements - #1167

Open
oioki wants to merge 1 commit into
ecomfe:masterfrom
oioki:fix/clear-with-textcontent
Open

fix: use textContent instead of innerHTML to clear elements#1167
oioki wants to merge 1 commit into
ecomfe:masterfrom
oioki:fix/clear-with-textcontent

Conversation

@oioki

@oioki oioki commented Aug 20, 2026

Copy link
Copy Markdown

Assigning to innerHTML is a Trusted Types injection sink. On a page sending require-trusted-types-for 'script', the browser rejects the assignment even when the value is an empty string — so zrender throws in dispose(), and on clip-path and gradient updates.

textContent = '' clears children identically and is not a sink.

svg/Painter.ts#clear() assigned null, relying on [LegacyNullToEmptyString]; it now assigns ''.

Assigning to innerHTML is a Trusted Types injection sink, rejected even
when the value is an empty string. textContent = '' clears children
identically and is not a sink.
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.

1 participant