Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions packages/@lwc/template-compiler/src/codegen/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,6 @@ import type {
import type { APIVersion } from '@lwc/shared';
import type { Node } from 'estree';

// structuredClone is only available in Node 17+
// https://developer.mozilla.org/en-US/docs/Web/API/structuredClone#browser_compatibility
const doStructuredClone =
typeof structuredClone === 'function'
? structuredClone
: (obj: any) => JSON.parse(JSON.stringify(obj));

type RenderPrimitive =
| 'iterator'
| 'flatten'
Expand Down Expand Up @@ -649,7 +642,7 @@ export default class CodeGen {
if (this.state.config.experimentalComplexExpressions) {
// Cloning here is necessary because `this.replace()` is destructive, and we might use the
// node later during static content optimization
expression = doStructuredClone(expression);
expression = structuredClone(expression);
return bindComplexExpression(expression as ComplexExpression, this);
}

Expand All @@ -659,7 +652,7 @@ export default class CodeGen {

// Cloning here is necessary because `this.replace()` is destructive, and we might use the
// node later during static content optimization
expression = doStructuredClone(expression);
expression = structuredClone(expression);
// TODO [#3370]: when the template expression flag is removed, the
// ComplexExpression type should be redefined as an ESTree Node. Doing
// so when the flag is still in place results in a cascade of required
Expand Down