Repository navigation
ref(deps): Patch zrender to clear nodes with textContent #125290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| Subject: use textContent instead of innerHTML to clear elements | ||
|
|
||
| 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, so charts keep working under require-trusted-types-for 'script'. | ||
|
|
||
| Submitted upstream as https://github.com/ecomfe/zrender/pull/1167. Drop this | ||
| patch once that lands and we pick up a release containing it. | ||
|
|
||
| Note the upstream PR edits src/*.ts, which cannot replace this patch: the | ||
| published package resolves its `module` entry through index.js to lib/*.js, so | ||
| the compiled output is what the bundler sees and what has to be patched here. | ||
| --- | ||
| diff --git a/lib/canvas/Painter.js b/lib/canvas/Painter.js | ||
| index 78dc6c8d46eca79366f5190a7c191410f8133816..3c79bc4e8abc8917458a0297159c5a0a307b01c8 100644 | ||
| --- a/lib/canvas/Painter.js | ||
| +++ b/lib/canvas/Painter.js | ||
| @@ -111,7 +111,7 @@ var CanvasPainter = (function () { | ||
| var rootStyle = root.style; | ||
| if (rootStyle) { | ||
| util.disableUserSelect(root); | ||
| - root.innerHTML = ''; | ||
| + root.textContent = ''; | ||
| } | ||
| this.storage = storage; | ||
| this._prevDisplayList = []; | ||
| @@ -685,7 +685,7 @@ var CanvasPainter = (function () { | ||
| }); | ||
| }; | ||
| CanvasPainter.prototype.dispose = function () { | ||
| - this.root.innerHTML = ''; | ||
| + this.root.textContent = ''; | ||
| this.root = | ||
| this.storage = | ||
| this._domRoot = | ||
| diff --git a/lib/svg/Painter.js b/lib/svg/Painter.js | ||
| index 2db019c7e9ac4b13947d0bb9220fdecbfa591d2f..b514a95dd529b76e1bea37953dfd00ed065f4b5a 100644 | ||
| --- a/lib/svg/Painter.js | ||
| +++ b/lib/svg/Painter.js | ||
| @@ -187,7 +187,7 @@ var SVGPainter = (function () { | ||
| }; | ||
| SVGPainter.prototype.dispose = function () { | ||
| if (this.root) { | ||
| - this.root.innerHTML = ''; | ||
| + this.root.textContent = ''; | ||
| } | ||
| this._svgDom = | ||
| this._viewport = | ||
| @@ -198,7 +198,7 @@ var SVGPainter = (function () { | ||
| }; | ||
| SVGPainter.prototype.clear = function () { | ||
| if (this._svgDom) { | ||
| - this._svgDom.innerHTML = null; | ||
| + this._svgDom.textContent = ''; | ||
| } | ||
| this._oldVNode = null; | ||
| }; | ||
| diff --git a/lib/svg-legacy/Painter.js b/lib/svg-legacy/Painter.js | ||
| index 5ca3b0d2fb308a7e9019a5dcb0869ce05ea130db..a818d6be22e8fa7c35634841d02eefd503a24828 100644 | ||
| --- a/lib/svg-legacy/Painter.js | ||
| +++ b/lib/svg-legacy/Painter.js | ||
| @@ -258,7 +258,7 @@ var SVGPainter = (function () { | ||
| return this._height; | ||
| }; | ||
| SVGPainter.prototype.dispose = function () { | ||
| - this.root.innerHTML = ''; | ||
| + this.root.textContent = ''; | ||
| this._svgRoot = | ||
| this._backgroundRoot = | ||
| this._svgDom = | ||
| diff --git a/lib/svg-legacy/helper/ClippathManager.js b/lib/svg-legacy/helper/ClippathManager.js | ||
| index d99b65aeec73c96cb3d981a87752467819757517..1383275a0c58c5e86ec029eb05a4eaf18ad5ef44 100644 | ||
| --- a/lib/svg-legacy/helper/ClippathManager.js | ||
| +++ b/lib/svg-legacy/helper/ClippathManager.js | ||
| @@ -73,7 +73,7 @@ var ClippathManager = (function (_super) { | ||
| } | ||
| path.brush(clipPath); | ||
| var pathEl = this.getSvgElement(clipPath); | ||
| - clipPathEl.innerHTML = ''; | ||
| + clipPathEl.textContent = ''; | ||
| clipPathEl.appendChild(pathEl); | ||
| parentEl.setAttribute('clip-path', getIdURL(id)); | ||
| if (clipPaths.length > 1) { | ||
| diff --git a/lib/svg-legacy/helper/GradientManager.js b/lib/svg-legacy/helper/GradientManager.js | ||
| index 7d413a137ebdc956c646e293820a745812b98a15..e802f747bae4e6b94271bb840958ee883047f55e 100644 | ||
| --- a/lib/svg-legacy/helper/GradientManager.js | ||
| +++ b/lib/svg-legacy/helper/GradientManager.js | ||
| @@ -96,7 +96,7 @@ var GradientManager = (function (_super) { | ||
| dom.setAttribute('gradientUnits', gradient.global | ||
| ? 'userSpaceOnUse' | ||
| : 'objectBoundingBox'); | ||
| - dom.innerHTML = ''; | ||
| + dom.textContent = ''; | ||
| var colors = gradient.colorStops; | ||
| for (var i = 0, len = colors.length; i < len; ++i) { | ||
| var stop_1 = createElement('stop'); | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
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?