Repository navigation
fix(loggerCodeViewer): avoid replaceChildren() so the viewer renders under Lightning Locker - #1038
Open
yassine2med wants to merge 1 commit into
Open
yassine2med wants to merge 1 commit into
yassine2med wants to merge 1 commit into
Conversation
…under Lightning Locker Lightning Locker's SecureElement proxy does not implement replaceChildren(), so _renderPrismHtml() threw and no code was rendered in orgs with LWS disabled (v4.19.0+). Clear the container with innerHTML = '' and appendChild() instead. Adds a regression test that removes Element.prototype.replaceChildren; it fails with the old code and passes now. Fixes jongpie#1034
This branch has not been deployed
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.
In orgs with Lightning Web Security disabled, Lightning Locker wraps DOM elements in
SecureElementproxies, which do not implementreplaceChildren(). Since v4.19.0_renderPrismHtml()calledcontainer.replaceChildren(preElement), so it threwreplaceChildren is not a functionand no code was rendered on theLogEntry__cpage or in the View Full Source modal.This clears the container with
innerHTML = ''and then callsappendChild(), the same approach v4.18.4 and earlier used.Tests: added a regression test to
loggerCodeViewer.test.jsthat removesElement.prototype.replaceChildren. It fails on the old code (container.replaceChildren is not a function) and passes now. All 19 LWC suites (337 tests) pass and prettier is clean. I could not run the Apex tests or check a Locker org myself.Fixes #1034
🤖 Generated with Claude Code
https://claude.ai/code/session_01CakWWNeSCYx1PiJnozyrTB