Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: apply static parts optimization to dynamic text (#4099)
* perf: enable static content optimization for dynamic text * test: new template-compiler tests * test: update existing template compiler tests * test: add karma tests * chore: update based on review feedback * chore: update test fixtures * Update packages/@lwc/template-compiler/src/codegen/codegen.ts Co-authored-by: Nolan Lawson <nlawson@salesforce.com> * chore: update based on pr feedback --------- Co-authored-by: Nolan Lawson <nlawson@salesforce.com>
- Loading branch information
1 parent
8d9da28
commit ea41be4
Showing
146 changed files
with
8,562 additions
and
1,391 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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,44 @@ | ||
/* | ||
* Copyright (c) 2024, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: MIT | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT | ||
*/ | ||
import { isNull } from '@lwc/shared'; | ||
import { RendererAPI } from '../renderer'; | ||
import { lockDomMutation, unlockDomMutation } from '../restrictions'; | ||
import { VComment, VStaticPartText, VText } from '../vnodes'; | ||
|
||
export function patchTextVNode(n1: VText, n2: VText, renderer: RendererAPI) { | ||
n2.elm = n1.elm; | ||
|
||
if (n2.text !== n1.text) { | ||
updateTextContent(n2, renderer); | ||
} | ||
} | ||
|
||
export function patchTextVStaticPart( | ||
n1: VStaticPartText | null, | ||
n2: VStaticPartText, | ||
renderer: RendererAPI | ||
) { | ||
if (isNull(n1) || n2.text !== n1.text) { | ||
updateTextContent(n2, renderer); | ||
} | ||
} | ||
|
||
export function updateTextContent( | ||
vnode: VText | VComment | VStaticPartText, | ||
renderer: RendererAPI | ||
) { | ||
const { elm, text } = vnode; | ||
const { setText } = renderer; | ||
|
||
if (process.env.NODE_ENV !== 'production') { | ||
unlockDomMutation(); | ||
} | ||
setText(elm, text); | ||
if (process.env.NODE_ENV !== 'production') { | ||
lockDomMutation(); | ||
} | ||
} |
This file contains 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
Oops, something went wrong.