diff --git a/package.json b/package.json index 1b4a59cc7f..52c495044e 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,6 @@ "@rollup/plugin-typescript": "^11.1.6", "@types/babel__core": "^7.20.5", "@types/node": "^22.1.0", - "@types/prettier": "^2.7.3", "@vitest/coverage-v8": "^2.0.5", "@vitest/ui": "^2.0.5", "bytes": "^3.1.2", @@ -64,7 +63,7 @@ "lint-staged": "^15.2.8", "magic-string": "^0.30.11", "nx": "19.5.6", - "prettier": "^2.8.8", + "prettier": "^3.3.3", "rollup": "^4.20.0", "terser": "^5.31.3", "tslib": "^2.6.3", diff --git a/packages/@lwc/babel-plugin-component/src/decorators/api/transform.ts b/packages/@lwc/babel-plugin-component/src/decorators/api/transform.ts index f156a0cd51..6dcf2c5464 100644 --- a/packages/@lwc/babel-plugin-component/src/decorators/api/transform.ts +++ b/packages/@lwc/babel-plugin-component/src/decorators/api/transform.ts @@ -55,30 +55,33 @@ function computePublicPropsConfig( publicPropertyMetas: DecoratorMeta[], classBodyItems: NodePath[] ) { - return publicPropertyMetas.reduce((acc, { propertyName, decoratedNodeType }) => { - if (!(propertyName in acc)) { - acc[propertyName] = {}; - } - acc[propertyName].config |= getPropertyBitmask(decoratedNodeType); + return publicPropertyMetas.reduce( + (acc, { propertyName, decoratedNodeType }) => { + if (!(propertyName in acc)) { + acc[propertyName] = {}; + } + acc[propertyName].config |= getPropertyBitmask(decoratedNodeType); - if ( - decoratedNodeType === DECORATOR_TYPES.GETTER || - decoratedNodeType === DECORATOR_TYPES.SETTER - ) { - // With the latest decorator spec, only one of the getter/setter pair needs a decorator. - // We need to add the proper bitmask for the sibling getter/setter if it exists. - const pairType = getSiblingGetSetPairType( - propertyName, - decoratedNodeType, - classBodyItems - ); - if (pairType) { - acc[propertyName].config |= getPropertyBitmask(pairType); + if ( + decoratedNodeType === DECORATOR_TYPES.GETTER || + decoratedNodeType === DECORATOR_TYPES.SETTER + ) { + // With the latest decorator spec, only one of the getter/setter pair needs a decorator. + // We need to add the proper bitmask for the sibling getter/setter if it exists. + const pairType = getSiblingGetSetPairType( + propertyName, + decoratedNodeType, + classBodyItems + ); + if (pairType) { + acc[propertyName].config |= getPropertyBitmask(pairType); + } } - } - return acc; - }, {} as { [key: string]: { [key: string]: number } }); + return acc; + }, + {} as { [key: string]: { [key: string]: number } } + ); } export default function transform( diff --git a/packages/@lwc/babel-plugin-component/src/decorators/index.ts b/packages/@lwc/babel-plugin-component/src/decorators/index.ts index 31cce4871a..8ab1c7137f 100644 --- a/packages/@lwc/babel-plugin-component/src/decorators/index.ts +++ b/packages/@lwc/babel-plugin-component/src/decorators/index.ts @@ -77,19 +77,22 @@ function validateImportedLwcDecoratorUsage( ) { engineImportSpecifiers .filter(({ name }) => isLwcDecoratorName(name)) - .reduce((acc, { name, path }) => { - // Get a list of all the local references - const local = path.get('imported') as NodePath; - const references = getReferences(local).map((reference) => ({ - name, - reference, - })); - - return [...acc, ...references] as { - name: string; - reference: NodePath; - }[]; - }, [] as { name: string; reference: NodePath }[]) + .reduce( + (acc, { name, path }) => { + // Get a list of all the local references + const local = path.get('imported') as NodePath; + const references = getReferences(local).map((reference) => ({ + name, + reference, + })); + + return [...acc, ...references] as { + name: string; + reference: NodePath; + }[]; + }, + [] as { name: string; reference: NodePath }[] + ) .forEach(({ name, reference }) => { // Get the decorator from the identifier // If the the decorator is: diff --git a/packages/@lwc/babel-plugin-component/src/decorators/track/index.ts b/packages/@lwc/babel-plugin-component/src/decorators/track/index.ts index de1d2759d5..894d178a1d 100644 --- a/packages/@lwc/babel-plugin-component/src/decorators/track/index.ts +++ b/packages/@lwc/babel-plugin-component/src/decorators/track/index.ts @@ -36,10 +36,13 @@ function transform(t: BabelTypes, decoratorMetas: DecoratorMeta[]) { const objectProperties = []; const trackDecoratorMetas = decoratorMetas.filter(isTrackDecorator); if (trackDecoratorMetas.length) { - const config = trackDecoratorMetas.reduce((acc, meta) => { - acc[meta.propertyName] = TRACK_PROPERTY_VALUE; - return acc; - }, {} as { [key: string]: number }); + const config = trackDecoratorMetas.reduce( + (acc, meta) => { + acc[meta.propertyName] = TRACK_PROPERTY_VALUE; + return acc; + }, + {} as { [key: string]: number } + ); objectProperties.push( t.objectProperty(t.identifier(LWC_COMPONENT_PROPERTIES.TRACK), t.valueToNode(config)) ); diff --git a/packages/@lwc/babel-plugin-component/src/decorators/wire/transform.ts b/packages/@lwc/babel-plugin-component/src/decorators/wire/transform.ts index 9f2cfebb9b..5b8cf3d84c 100644 --- a/packages/@lwc/babel-plugin-component/src/decorators/wire/transform.ts +++ b/packages/@lwc/babel-plugin-component/src/decorators/wire/transform.ts @@ -267,7 +267,7 @@ export default function transform(t: BabelTypes, decoratorMetas: DecoratorMeta[] const wiredValues = decoratorMetas.filter(isWireDecorator).map(({ path }) => { const [id, config] = path.get('expression.arguments') as [ NodePath, - NodePath | undefined + NodePath | undefined, ]; const propertyName = (path.parentPath.get('key.name') as any).node as string; diff --git a/packages/@lwc/engine-core/src/framework/base-lightning-element.ts b/packages/@lwc/engine-core/src/framework/base-lightning-element.ts index 45a046007e..4db74e37be 100644 --- a/packages/@lwc/engine-core/src/framework/base-lightning-element.ts +++ b/packages/@lwc/engine-core/src/framework/base-lightning-element.ts @@ -810,7 +810,7 @@ if (process.env.IS_BROWSER) { // aria* properties for (const [propName, descriptor] of entries(ariaReflectionPolyfillDescriptors) as [ name: string, - descriptor: PropertyDescriptor + descriptor: PropertyDescriptor, ][]) { lightningBasedDescriptors[propName] = createBridgeToElementDescriptor(propName, descriptor); } diff --git a/packages/@lwc/engine-core/src/framework/wiring/types.ts b/packages/@lwc/engine-core/src/framework/wiring/types.ts index 11f4cfb312..5216ae5670 100644 --- a/packages/@lwc/engine-core/src/framework/wiring/types.ts +++ b/packages/@lwc/engine-core/src/framework/wiring/types.ts @@ -15,7 +15,7 @@ export type ContextValue = Record; export interface WireAdapter< Config extends ConfigValue = ConfigValue, - Context extends ContextValue = ContextValue + Context extends ContextValue = ContextValue, > { update(config: Config, context?: Context): void; connect(): void; @@ -25,12 +25,12 @@ export interface WireAdapter< export interface WireAdapterConstructor< Config extends ConfigValue = ConfigValue, Value = any, - Context extends ContextValue = ContextValue + Context extends ContextValue = ContextValue, > { - new (callback: DataCallback, sourceContext?: { tagName: string }): WireAdapter< - Config, - Context - >; + new ( + callback: DataCallback, + sourceContext?: { tagName: string } + ): WireAdapter; configSchema?: Record; contextSchema?: Record; } diff --git a/packages/@lwc/integration-karma/scripts/karma-plugins/hydration-tests.js b/packages/@lwc/integration-karma/scripts/karma-plugins/hydration-tests.js index c645fa4c80..3e795504be 100644 --- a/packages/@lwc/integration-karma/scripts/karma-plugins/hydration-tests.js +++ b/packages/@lwc/integration-karma/scripts/karma-plugins/hydration-tests.js @@ -151,12 +151,10 @@ function createHCONFIG2JSPreprocessor(config, logger, emitter) { const describeTitle = path.relative(basePath, suiteDir).split(path.sep).join(' '); try { - const { code: testCode, watchFiles: testWatchFiles } = await getTestModuleCode( - filePath - ); - const { code: componentDef, watchFiles: componentWatchFiles } = await getCompiledModule( - suiteDir - ); + const { code: testCode, watchFiles: testWatchFiles } = + await getTestModuleCode(filePath); + const { code: componentDef, watchFiles: componentWatchFiles } = + await getCompiledModule(suiteDir); // You can add an `.only` file alongside an `index.spec.js` file to make it `fdescribe()` const onlyFileExists = await exists(path.join(suiteDir, '.only')); diff --git a/packages/@lwc/integration-karma/test/light-dom/slot-fowarding/slots/forwarding/index.spec.js b/packages/@lwc/integration-karma/test/light-dom/slot-fowarding/slots/forwarding/index.spec.js index 8404b2378d..3c87d8681b 100644 --- a/packages/@lwc/integration-karma/test/light-dom/slot-fowarding/slots/forwarding/index.spec.js +++ b/packages/@lwc/integration-karma/test/light-dom/slot-fowarding/slots/forwarding/index.spec.js @@ -91,13 +91,13 @@ describe('slot forwarding', () => { const defaultSlotTextIndex = USE_LIGHT_DOM_SLOT_FORWARDING ? 12 : USE_COMMENTS_FOR_FRAGMENT_BOOKENDS - ? 11 - : 4; + ? 11 + : 4; const defaultSlotCommentIndex = USE_LIGHT_DOM_SLOT_FORWARDING ? 13 : USE_COMMENTS_FOR_FRAGMENT_BOOKENDS - ? 12 - : 5; + ? 12 + : 5; expect(lightLightLeaf.childNodes[defaultSlotTextIndex].textContent).toEqual( expectedDefaultSlot.textContent diff --git a/packages/@lwc/integration-karma/test/rendering/callback-invocation-order/index.spec.js b/packages/@lwc/integration-karma/test/rendering/callback-invocation-order/index.spec.js index 4a72fded34..be148d43b7 100644 --- a/packages/@lwc/integration-karma/test/rendering/callback-invocation-order/index.spec.js +++ b/packages/@lwc/integration-karma/test/rendering/callback-invocation-order/index.spec.js @@ -328,20 +328,20 @@ describe('regression test (#3827)', () => { process.env.NATIVE_SHADOW ? [] : !lwcRuntimeFlags.DISABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE - ? [ - `leaf:${currentLeafName}:connectedCallback`, - `leaf:${previousLeafName}:disconnectedCallback`, - ] - : [`leaf:${currentLeafName}:connectedCallback`], + ? [ + `leaf:${currentLeafName}:connectedCallback`, + `leaf:${previousLeafName}:disconnectedCallback`, + ] + : [`leaf:${currentLeafName}:connectedCallback`], elseIfBlock: (currentLeafName, previousLeafName) => process.env.NATIVE_SHADOW ? [] : !lwcRuntimeFlags.DISABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE - ? [ - `leaf:${currentLeafName}:connectedCallback`, - `leaf:${previousLeafName}:disconnectedCallback`, - ] - : [`leaf:${currentLeafName}:connectedCallback`], + ? [ + `leaf:${currentLeafName}:connectedCallback`, + `leaf:${previousLeafName}:disconnectedCallback`, + ] + : [`leaf:${currentLeafName}:connectedCallback`], }, { fixtureName: 'light DOM', diff --git a/packages/@lwc/integration-tests/README.md b/packages/@lwc/integration-tests/README.md index 2851cab1ba..566ce7123b 100644 --- a/packages/@lwc/integration-tests/README.md +++ b/packages/@lwc/integration-tests/README.md @@ -137,7 +137,7 @@ Here `` would be the broader area under test such as events, sl In the above example, `app` and `child` are present because the test verifies event handling between a child and parent component and to reflect the playground setup, but are not required for every test. `.html` may also use the `` template currently used in some lwc-integration tests to cleanly display Github issue and Lightning Web Components playground links. -The level describe blocks inside `.spec.js` should also note the Github issue number if relevant. For example, `` describe('Issue 657: Cannot attach event in `connectedCallback`', () => {...}) ``. +The level describe blocks inside `.spec.js` should also note the Github issue number if relevant. For example, ``describe('Issue 657: Cannot attach event in `connectedCallback`', () => {...})``. If it doesn't require additional components for the repro, you could simply have diff --git a/packages/@lwc/ssr-compiler/src/compile-template/text.ts b/packages/@lwc/ssr-compiler/src/compile-template/text.ts index e560c9aa1d..ffdf883aaa 100644 --- a/packages/@lwc/ssr-compiler/src/compile-template/text.ts +++ b/packages/@lwc/ssr-compiler/src/compile-template/text.ts @@ -37,7 +37,7 @@ const bYieldEscapedString = esTemplateWithYield< EsIdentifier, EsIdentifier, EsIdentifier, - EsIdentifier + EsIdentifier, ] >` const ${is.identifier} = ${is.expression}; diff --git a/packages/@lwc/ssr-compiler/src/estemplate.ts b/packages/@lwc/ssr-compiler/src/estemplate.ts index 0a1d429773..5ca735eba9 100644 --- a/packages/@lwc/ssr-compiler/src/estemplate.ts +++ b/packages/@lwc/ssr-compiler/src/estemplate.ts @@ -139,7 +139,7 @@ function esTemplateImpl( javascriptSegments: TemplateStringsArray, ...validatorFns: Validator[] @@ -149,7 +149,7 @@ export function esTemplate< export function esTemplateWithYield< RetType = EsNode, - ArgTypes extends ReplacementNode[] = ReplacementNode[] + ArgTypes extends ReplacementNode[] = ReplacementNode[], >( javascriptSegments: TemplateStringsArray, ...validatorFns: Validator[] diff --git a/packages/@lwc/ssr-runtime/src/index.ts b/packages/@lwc/ssr-runtime/src/index.ts index cdbb0cf69c..fd219c741e 100644 --- a/packages/@lwc/ssr-runtime/src/index.ts +++ b/packages/@lwc/ssr-runtime/src/index.ts @@ -124,7 +124,7 @@ export class LightningElement { getAttribute(attrName: string): string | null { const value = this.__attrs?.[attrName]; - return value === true ? '' : value ?? null; + return value === true ? '' : (value ?? null); } } diff --git a/packages/@lwc/synthetic-shadow/src/faux-shadow/element.ts b/packages/@lwc/synthetic-shadow/src/faux-shadow/element.ts index 3ac39619e4..293c8608bf 100644 --- a/packages/@lwc/synthetic-shadow/src/faux-shadow/element.ts +++ b/packages/@lwc/synthetic-shadow/src/faux-shadow/element.ts @@ -408,7 +408,7 @@ if (process.env.NODE_ENV !== 'test') { this, ArraySlice.call(arguments as unknown as unknown[]) as [ namespace: string, - localName: string + localName: string, ] ) ); diff --git a/packages/@lwc/synthetic-shadow/src/faux-shadow/slot.ts b/packages/@lwc/synthetic-shadow/src/faux-shadow/slot.ts index 0e09aab1ed..acd480a4a4 100644 --- a/packages/@lwc/synthetic-shadow/src/faux-shadow/slot.ts +++ b/packages/@lwc/synthetic-shadow/src/faux-shadow/slot.ts @@ -156,7 +156,7 @@ defineProperties(HTMLSlotElement.prototype, { return originalAssignedElements.apply( this, ArraySlice.call(arguments as unknown as unknown[]) as [ - options?: AssignedNodesOptions + options?: AssignedNodesOptions, ] ); } @@ -176,7 +176,7 @@ defineProperties(HTMLSlotElement.prototype, { return originalAssignedNodes.apply( this, ArraySlice.call(arguments as unknown as unknown[]) as [ - options?: AssignedNodesOptions + options?: AssignedNodesOptions, ] ); } diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures.spec.ts b/packages/@lwc/template-compiler/src/__tests__/fixtures.spec.ts index 15171d2903..c1c692abb4 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures.spec.ts +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures.spec.ts @@ -18,7 +18,7 @@ describe('fixtures', () => { root: path.resolve(__dirname, 'fixtures'), pattern: '**/actual.html', }, - ({ src, dirname }) => { + async ({ src, dirname }) => { const configPath = path.resolve(dirname, 'config.json'); const filename = path.basename(dirname); @@ -38,8 +38,10 @@ describe('fixtures', () => { ); return { - // TODO [#4386]: Prettier v3 returns a promise - add an `await` here - 'expected.js': prettier.format(code, { parser: 'babel' }), + 'expected.js': await prettier.format(code, { + parser: 'babel', + trailingComma: 'es5', + }), 'ast.json': JSON.stringify({ root }, null, 4), 'metadata.json': JSON.stringify({ warnings }, null, 4), }; diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic-components/if-elseif-else-nested/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic-components/if-elseif-else-nested/expected.js index 9b5aa0189f..e48ce7d27d 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic-components/if-elseif-else-nested/expected.js +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic-components/if-elseif-else-nested/expected.js @@ -20,26 +20,30 @@ function tmpl($api, $cmp, $slotset, $ctx) { $cmp.outer.if ? api_fragment(0, [api_static_fragment($fragment1, 2)], 0) : $cmp.outer.elseif1 - ? api_fragment(0, [api_static_fragment($fragment2, 4)], 0) - : $cmp.outer.elseif2 - ? api_fragment( - 0, - [ - $cmp.inner.if - ? api_fragment(5, [api_static_fragment($fragment3, 7)], 0) - : $cmp.inner.elseif - ? api_fragment(5, [api_static_fragment($fragment4, 9)], 0) - : $cmp.inner.elseif2 - ? api_fragment( - 5, - [api_dynamic_component($cmp.trackedProp.foo, stc0)], - 0 - ) - : api_fragment(5, [api_static_fragment($fragment5, 12)], 0), - ], - 0 - ) - : api_fragment(0, [api_static_fragment($fragment6, 14)], 0), + ? api_fragment(0, [api_static_fragment($fragment2, 4)], 0) + : $cmp.outer.elseif2 + ? api_fragment( + 0, + [ + $cmp.inner.if + ? api_fragment(5, [api_static_fragment($fragment3, 7)], 0) + : $cmp.inner.elseif + ? api_fragment(5, [api_static_fragment($fragment4, 9)], 0) + : $cmp.inner.elseif2 + ? api_fragment( + 5, + [api_dynamic_component($cmp.trackedProp.foo, stc0)], + 0 + ) + : api_fragment( + 5, + [api_static_fragment($fragment5, 12)], + 0 + ), + ], + 0 + ) + : api_fragment(0, [api_static_fragment($fragment6, 14)], 0), ]; /*LWC compiler vX.X.X*/ } diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic-components/if-elseif-else/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic-components/if-elseif-else/expected.js index ad5c124e56..be231663e1 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic-components/if-elseif-else/expected.js +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic-components/if-elseif-else/expected.js @@ -16,8 +16,12 @@ function tmpl($api, $cmp, $slotset, $ctx) { $cmp.visible.if ? api_fragment(0, [api_static_fragment($fragment1, 2)], 0) : $cmp.visible.elseif - ? api_fragment(0, [api_static_fragment($fragment2, 4)], 0) - : api_fragment(0, [api_dynamic_component($cmp.trackedProp.foo, stc0)], 0), + ? api_fragment(0, [api_static_fragment($fragment2, 4)], 0) + : api_fragment( + 0, + [api_dynamic_component($cmp.trackedProp.foo, stc0)], + 0 + ), ]; /*LWC compiler vX.X.X*/ } diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic-components/if-elseif-multiple/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic-components/if-elseif-multiple/expected.js index 9c36a2d0c4..c0bff10c59 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic-components/if-elseif-multiple/expected.js +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic-components/if-elseif-multiple/expected.js @@ -17,10 +17,14 @@ function tmpl($api, $cmp, $slotset, $ctx) { $cmp.visible.if ? api_fragment(0, [api_static_fragment($fragment1, 2)], 0) : $cmp.visible.elseif - ? api_fragment(0, [api_static_fragment($fragment2, 4)], 0) - : $cmp.visible.elseif2 - ? api_fragment(0, [api_dynamic_component($cmp.trackedProp.foo, stc0)], 0) - : api_fragment(0, [api_static_fragment($fragment3, 7)], 0), + ? api_fragment(0, [api_static_fragment($fragment2, 4)], 0) + : $cmp.visible.elseif2 + ? api_fragment( + 0, + [api_dynamic_component($cmp.trackedProp.foo, stc0)], + 0 + ) + : api_fragment(0, [api_static_fragment($fragment3, 7)], 0), ]; /*LWC compiler vX.X.X*/ } diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic-components/if-elseif/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic-components/if-elseif/expected.js index e027488955..9febbd9d00 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic-components/if-elseif/expected.js +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic-components/if-elseif/expected.js @@ -15,8 +15,12 @@ function tmpl($api, $cmp, $slotset, $ctx) { $cmp.visible.if ? api_fragment(0, [api_static_fragment($fragment1, 2)], 0) : $cmp.visible.elseif - ? api_fragment(0, [api_dynamic_component($cmp.trackedProp.foo, stc0)], 0) - : null, + ? api_fragment( + 0, + [api_dynamic_component($cmp.trackedProp.foo, stc0)], + 0 + ) + : null, ]; /*LWC compiler vX.X.X*/ } diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic-components/inline/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic-components/inline/expected.js index d3b7aa87a6..c8ab45175c 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic-components/inline/expected.js +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic-components/inline/expected.js @@ -31,24 +31,24 @@ function tmpl($api, $cmp, $slotset, $ctx) { 0 ) : $cmp.visible.elseif - ? api_fragment( - 0, - [ - api_dynamic_component($cmp.ctor2, stc1, [ - api_static_fragment($fragment2, 6), - ]), - ], - 0 - ) - : api_fragment( - 0, - [ - api_dynamic_component($cmp.ctor3, stc2, [ - api_static_fragment($fragment3, 9), - ]), - ], - 0 - ), + ? api_fragment( + 0, + [ + api_dynamic_component($cmp.ctor2, stc1, [ + api_static_fragment($fragment2, 6), + ]), + ], + 0 + ) + : api_fragment( + 0, + [ + api_dynamic_component($cmp.ctor3, stc2, [ + api_static_fragment($fragment3, 9), + ]), + ], + 0 + ), ]; /*LWC compiler vX.X.X*/ } diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic/if-elseif-else-nested/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic/if-elseif-else-nested/expected.js index 8c22d0acbe..9886a4717e 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic/if-elseif-else-nested/expected.js +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic/if-elseif-else-nested/expected.js @@ -20,32 +20,36 @@ function tmpl($api, $cmp, $slotset, $ctx) { $cmp.outer.if ? api_fragment(0, [api_static_fragment($fragment1, 2)], 0) : $cmp.outer.elseif1 - ? api_fragment(0, [api_static_fragment($fragment2, 4)], 0) - : $cmp.outer.elseif2 - ? api_fragment( - 0, - [ - $cmp.inner.if - ? api_fragment(5, [api_static_fragment($fragment3, 7)], 0) - : $cmp.inner.elseif - ? api_fragment(5, [api_static_fragment($fragment4, 9)], 0) - : $cmp.inner.elseif2 - ? api_fragment( - 5, - [ - api_deprecated_dynamic_component( - "x-foo", - $cmp.trackedProp.foo, - stc0 - ), - ], - 0 - ) - : api_fragment(5, [api_static_fragment($fragment5, 12)], 0), - ], - 0 - ) - : api_fragment(0, [api_static_fragment($fragment6, 14)], 0), + ? api_fragment(0, [api_static_fragment($fragment2, 4)], 0) + : $cmp.outer.elseif2 + ? api_fragment( + 0, + [ + $cmp.inner.if + ? api_fragment(5, [api_static_fragment($fragment3, 7)], 0) + : $cmp.inner.elseif + ? api_fragment(5, [api_static_fragment($fragment4, 9)], 0) + : $cmp.inner.elseif2 + ? api_fragment( + 5, + [ + api_deprecated_dynamic_component( + "x-foo", + $cmp.trackedProp.foo, + stc0 + ), + ], + 0 + ) + : api_fragment( + 5, + [api_static_fragment($fragment5, 12)], + 0 + ), + ], + 0 + ) + : api_fragment(0, [api_static_fragment($fragment6, 14)], 0), ]; /*LWC compiler vX.X.X*/ } diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic/if-elseif-else/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic/if-elseif-else/expected.js index 69b1895cf4..ba5537b950 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic/if-elseif-else/expected.js +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic/if-elseif-else/expected.js @@ -16,18 +16,18 @@ function tmpl($api, $cmp, $slotset, $ctx) { $cmp.visible.if ? api_fragment(0, [api_static_fragment($fragment1, 2)], 0) : $cmp.visible.elseif - ? api_fragment(0, [api_static_fragment($fragment2, 4)], 0) - : api_fragment( - 0, - [ - api_deprecated_dynamic_component( - "x-foo", - $cmp.trackedProp.foo, - stc0 - ), - ], - 0 - ), + ? api_fragment(0, [api_static_fragment($fragment2, 4)], 0) + : api_fragment( + 0, + [ + api_deprecated_dynamic_component( + "x-foo", + $cmp.trackedProp.foo, + stc0 + ), + ], + 0 + ), ]; /*LWC compiler vX.X.X*/ } diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic/if-elseif-multiple/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic/if-elseif-multiple/expected.js index 604097aa74..9d0b3d8900 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic/if-elseif-multiple/expected.js +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic/if-elseif-multiple/expected.js @@ -17,20 +17,20 @@ function tmpl($api, $cmp, $slotset, $ctx) { $cmp.visible.if ? api_fragment(0, [api_static_fragment($fragment1, 2)], 0) : $cmp.visible.elseif - ? api_fragment(0, [api_static_fragment($fragment2, 4)], 0) - : $cmp.visible.elseif2 - ? api_fragment( - 0, - [ - api_deprecated_dynamic_component( - "x-foo", - $cmp.trackedProp.foo, - stc0 - ), - ], - 0 - ) - : api_fragment(0, [api_static_fragment($fragment3, 7)], 0), + ? api_fragment(0, [api_static_fragment($fragment2, 4)], 0) + : $cmp.visible.elseif2 + ? api_fragment( + 0, + [ + api_deprecated_dynamic_component( + "x-foo", + $cmp.trackedProp.foo, + stc0 + ), + ], + 0 + ) + : api_fragment(0, [api_static_fragment($fragment3, 7)], 0), ]; /*LWC compiler vX.X.X*/ } diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic/if-elseif/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic/if-elseif/expected.js index 8820fe5543..09fbd1003f 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic/if-elseif/expected.js +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/dynamic/if-elseif/expected.js @@ -15,18 +15,18 @@ function tmpl($api, $cmp, $slotset, $ctx) { $cmp.visible.if ? api_fragment(0, [api_static_fragment($fragment1, 2)], 0) : $cmp.visible.elseif - ? api_fragment( - 0, - [ - api_deprecated_dynamic_component( - "x-foo", - $cmp.trackedProp.foo, - stc0 - ), - ], - 0 - ) - : null, + ? api_fragment( + 0, + [ + api_deprecated_dynamic_component( + "x-foo", + $cmp.trackedProp.foo, + stc0 + ), + ], + 0 + ) + : null, ]; /*LWC compiler vX.X.X*/ } diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/if-elseif-else/components/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/if-elseif-else/components/expected.js index 430190ea26..ee221f4991 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/if-elseif-else/components/expected.js +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/if-elseif-else/components/expected.js @@ -19,16 +19,16 @@ function tmpl($api, $cmp, $slotset, $ctx) { $cmp.visible ? api_fragment(0, [api_custom_element("c-custom", _cCustom, stc0)], 0) : $cmp.elseif - ? api_fragment( - 0, - [api_custom_element("c-custom-elseif", _cCustomElseif, stc1)], - 0 - ) - : api_fragment( - 0, - [api_custom_element("c-custom-else", _cCustomElse, stc2)], - 0 - ), + ? api_fragment( + 0, + [api_custom_element("c-custom-elseif", _cCustomElseif, stc1)], + 0 + ) + : api_fragment( + 0, + [api_custom_element("c-custom-else", _cCustomElse, stc2)], + 0 + ), ]; /*LWC compiler vX.X.X*/ } diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/if-elseif-else/html-elements/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/if-elseif-else/html-elements/expected.js index 82ea813770..c0e40f7f09 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/if-elseif-else/html-elements/expected.js +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/if-elseif-else/html-elements/expected.js @@ -10,8 +10,8 @@ function tmpl($api, $cmp, $slotset, $ctx) { $cmp.visible ? api_fragment(0, [api_static_fragment($fragment1, 2)], 0) : $cmp.elseifCondition - ? api_fragment(0, [api_static_fragment($fragment2, 4)], 0) - : api_fragment(0, [api_static_fragment($fragment3, 6)], 0), + ? api_fragment(0, [api_static_fragment($fragment2, 4)], 0) + : api_fragment(0, [api_static_fragment($fragment3, 6)], 0), ]; /*LWC compiler vX.X.X*/ } diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/if-elseif-else/template/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/if-elseif-else/template/expected.js index 94a79fb9a7..8ef75f26bd 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/if-elseif-else/template/expected.js +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/if-elseif-else/template/expected.js @@ -7,8 +7,8 @@ function tmpl($api, $cmp, $slotset, $ctx) { $cmp.visible ? api_fragment(0, [api_text("Conditional Text")], 0) : $cmp.elseifCondition - ? api_fragment(0, [api_text("Elseif!")], 0) - : api_fragment(0, [api_text("Else!")], 0), + ? api_fragment(0, [api_text("Elseif!")], 0) + : api_fragment(0, [api_text("Else!")], 0), ]; /*LWC compiler vX.X.X*/ } diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/if-elseif/components/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/if-elseif/components/expected.js index 4fb9e41e70..a3af2ca6f3 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/if-elseif/components/expected.js +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/if-elseif/components/expected.js @@ -22,16 +22,16 @@ function tmpl($api, $cmp, $slotset, $ctx) { 0 ) : $cmp.elseifCondition - ? api_fragment( - 0, - [ - api_custom_element("c-custom", _cCustom, stc1, [ - api_text("First Alternative Header"), - ]), - ], - 0 - ) - : null, + ? api_fragment( + 0, + [ + api_custom_element("c-custom", _cCustom, stc1, [ + api_text("First Alternative Header"), + ]), + ], + 0 + ) + : null, ]; /*LWC compiler vX.X.X*/ } diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/if-elseif/html-elements/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/if-elseif/html-elements/expected.js index c29e0472a6..5d6e1be62d 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/if-elseif/html-elements/expected.js +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/if-elseif/html-elements/expected.js @@ -9,8 +9,8 @@ function tmpl($api, $cmp, $slotset, $ctx) { $cmp.visible ? api_fragment(0, [api_static_fragment($fragment1, 2)], 0) : $cmp.elseifCondition - ? api_fragment(0, [api_static_fragment($fragment2, 4)], 0) - : null, + ? api_fragment(0, [api_static_fragment($fragment2, 4)], 0) + : null, ]; /*LWC compiler vX.X.X*/ } diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/if-elseif/template/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/if-elseif/template/expected.js index c9b059d51e..09470cb1bd 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/if-elseif/template/expected.js +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/if-elseif/template/expected.js @@ -7,8 +7,8 @@ function tmpl($api, $cmp, $slotset, $ctx) { $cmp.visible ? api_fragment(0, [api_text("Conditional Text")], 0) : $cmp.displayAlt - ? api_fragment(0, [api_text("Elseif!")], 0) - : null, + ? api_fragment(0, [api_text("Elseif!")], 0) + : null, ]; /*LWC compiler vX.X.X*/ } diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/mixed-elements/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/mixed-elements/expected.js index 8fdaad2f22..f7ccb63110 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/mixed-elements/expected.js +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/mixed-elements/expected.js @@ -17,16 +17,16 @@ function tmpl($api, $cmp, $slotset, $ctx) { $cmp.visible ? api_fragment(0, [api_text("Conditional Text")], 0) : $cmp.elseifCondition - ? api_fragment(0, [api_static_fragment($fragment1, 2)], 0) - : api_fragment( - 0, - [ - api_custom_element("c-default", _cDefault, stc0, [ - api_text("Else!"), - ]), - ], - 0 - ), + ? api_fragment(0, [api_static_fragment($fragment1, 2)], 0) + : api_fragment( + 0, + [ + api_custom_element("c-default", _cDefault, stc0, [ + api_text("Else!"), + ]), + ], + 0 + ), ]; /*LWC compiler vX.X.X*/ } diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/nested/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/nested/expected.js index 49a33c6de8..96588fb60b 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/nested/expected.js +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/nested/expected.js @@ -39,69 +39,75 @@ function tmpl($api, $cmp, $slotset, $ctx) { $cmp.visible ? api_fragment(0, [api_custom_element("c-custom", _cCustom, stc0)], 0) : $cmp.elseif - ? api_fragment( - 0, - [ - api_custom_element("c-custom-elseif", _cCustomElseif, stc1, [ - api_text("If Text"), - $cmp.showNestedIf - ? api_fragment( - 3, - [ - api_custom_element("c-nested", _cNested, stc2, [ - $cmp.doubleNestedIf - ? api_fragment( - 5, - [ - api_custom_element( - "c-double-nested", - _cDoubleNested, - stc3 - ), - ], - 0 - ) - : api_fragment( - 5, - [ - api_custom_element( - "c-double-nested-else", - _cDoubleNestedElse, - stc4 - ), - ], - 0 - ), - ]), - ], - 0 - ) - : $cmp.elseifNested - ? api_fragment( - 3, - [ - api_custom_element( - "c-nested-elseif", - _cNestedElseif, - stc5 + ? api_fragment( + 0, + [ + api_custom_element("c-custom-elseif", _cCustomElseif, stc1, [ + api_text("If Text"), + $cmp.showNestedIf + ? api_fragment( + 3, + [ + api_custom_element("c-nested", _cNested, stc2, [ + $cmp.doubleNestedIf + ? api_fragment( + 5, + [ + api_custom_element( + "c-double-nested", + _cDoubleNested, + stc3 + ), + ], + 0 + ) + : api_fragment( + 5, + [ + api_custom_element( + "c-double-nested-else", + _cDoubleNestedElse, + stc4 + ), + ], + 0 + ), + ]), + ], + 0 + ) + : $cmp.elseifNested + ? api_fragment( + 3, + [ + api_custom_element( + "c-nested-elseif", + _cNestedElseif, + stc5 + ), + ], + 0 + ) + : api_fragment( + 3, + [ + api_custom_element( + "c-nested-else", + _cNestedElse, + stc6 + ), + ], + 0 ), - ], - 0 - ) - : api_fragment( - 3, - [api_custom_element("c-nested-else", _cNestedElse, stc6)], - 0 - ), - ]), - ], - 0 - ) - : api_fragment( - 0, - [api_custom_element("c-custom-else", _cCustomElse, stc7)], - 0 - ), + ]), + ], + 0 + ) + : api_fragment( + 0, + [api_custom_element("c-custom-else", _cCustomElse, stc7)], + 0 + ), ]; /*LWC compiler vX.X.X*/ } diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/slots/duplicate-slots-warning/not-in-same-condition-tree/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/slots/duplicate-slots-warning/not-in-same-condition-tree/expected.js index f96c0e4fb0..b34e4f8cd6 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/slots/duplicate-slots-warning/not-in-same-condition-tree/expected.js +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/slots/duplicate-slots-warning/not-in-same-condition-tree/expected.js @@ -32,29 +32,29 @@ function tmpl($api, $cmp, $slotset, $ctx) { $cmp.condition ? api_fragment(0, [api_text("Conditional Text")], 0) : $cmp.altCondition - ? api_fragment( - 0, - [ - api_element("div", stc0, [ - api_slot("outside-slot", stc1, stc2, $slotset), - ]), - ], - 0 - ) - : api_fragment(0, [api_slot("outside-slot", stc3, stc2, $slotset)], 0), + ? api_fragment( + 0, + [ + api_element("div", stc0, [ + api_slot("outside-slot", stc1, stc2, $slotset), + ]), + ], + 0 + ) + : api_fragment(0, [api_slot("outside-slot", stc3, stc2, $slotset)], 0), $cmp.anotherCondition ? api_fragment(4, [api_text("Another Conditional Text")], 0) : $cmp.anotherAltCondition - ? api_fragment( - 4, - [ - api_element("div", stc4, [ - api_slot("outside-slot", stc5, stc2, $slotset), - ]), - ], - 0 - ) - : null, + ? api_fragment( + 4, + [ + api_element("div", stc4, [ + api_slot("outside-slot", stc5, stc2, $slotset), + ]), + ], + 0 + ) + : null, ]; /*LWC compiler vX.X.X*/ } diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/slots/valid-duplicate-slot-names/complex/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/slots/valid-duplicate-slot-names/complex/expected.js index a8616f7641..4519cc003c 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/slots/valid-duplicate-slot-names/complex/expected.js +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/slots/valid-duplicate-slot-names/complex/expected.js @@ -73,39 +73,39 @@ function tmpl($api, $cmp, $slotset, $ctx) { $cmp.doubleNested ? api_fragment(4, [api_text("Double Nested")], 0) : $cmp.doubleNestedAlt - ? api_fragment( - 4, - [ - $cmp.tripleNested - ? api_fragment( - 5, - [ - api_element("div", stc3, [ - api_element("div", stc4, [ - api_text("Triple Nested Text"), - api_slot( - "nested-slot", - stc5, - stc1, - $slotset - ), + ? api_fragment( + 4, + [ + $cmp.tripleNested + ? api_fragment( + 5, + [ + api_element("div", stc3, [ + api_element("div", stc4, [ + api_text("Triple Nested Text"), + api_slot( + "nested-slot", + stc5, + stc1, + $slotset + ), + ]), ]), - ]), - ], - 0 - ) - : null, - ], - 0 - ) - : api_fragment( - 4, - [ - api_text("Else"), - api_slot("nested-slot", stc6, stc1, $slotset), - ], - 0 - ), + ], + 0 + ) + : null, + ], + 0 + ) + : api_fragment( + 4, + [ + api_text("Else"), + api_slot("nested-slot", stc6, stc1, $slotset), + ], + 0 + ), ], 0 ), diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/static-content-optimization/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/static-content-optimization/expected.js index ea1b5bff03..e2184d8ca2 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/static-content-optimization/expected.js +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/directive-lwc-if-else/static-content-optimization/expected.js @@ -45,56 +45,56 @@ function tmpl($api, $cmp, $slotset, $ctx) { 0 ) : $cmp.showElseIf - ? api_fragment( - 0, - [ - api_static_fragment($fragment4, 8, [ - api_static_part( - 0, - { - attrs: { - "data-dynamic": $cmp.insideElseIf, + ? api_fragment( + 0, + [ + api_static_fragment($fragment4, 8, [ + api_static_part( + 0, + { + attrs: { + "data-dynamic": $cmp.insideElseIf, + }, }, - }, - null - ), - ]), - api_static_fragment($fragment5, 10), - api_static_fragment($fragment6, 12, [ - api_static_part( - 1, - null, - "concatenated " + api_dynamic_text($cmp.insideElseIf) - ), - ]), - ], - 0 - ) - : api_fragment( - 0, - [ - api_static_fragment($fragment7, 14, [ - api_static_part( - 0, - { - attrs: { - "data-dynamic": $cmp.insideElse, + null + ), + ]), + api_static_fragment($fragment5, 10), + api_static_fragment($fragment6, 12, [ + api_static_part( + 1, + null, + "concatenated " + api_dynamic_text($cmp.insideElseIf) + ), + ]), + ], + 0 + ) + : api_fragment( + 0, + [ + api_static_fragment($fragment7, 14, [ + api_static_part( + 0, + { + attrs: { + "data-dynamic": $cmp.insideElse, + }, }, - }, - null - ), - ]), - api_static_fragment($fragment8, 16), - api_static_fragment($fragment9, 18, [ - api_static_part( - 1, - null, - "concatenated " + api_dynamic_text($cmp.insideElse) - ), - ]), - ], - 0 - ), + null + ), + ]), + api_static_fragment($fragment8, 16), + api_static_fragment($fragment9, 18, [ + api_static_part( + 1, + null, + "concatenated " + api_dynamic_text($cmp.insideElse) + ), + ]), + ], + 0 + ), ]; /*LWC compiler vX.X.X*/ } diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/scoped-slots/if-block/valid/mixed-slot-types/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/scoped-slots/if-block/valid/mixed-slot-types/expected.js index 37d1658713..9200e6922e 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/scoped-slots/if-block/valid/mixed-slot-types/expected.js +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/scoped-slots/if-block/valid/mixed-slot-types/expected.js @@ -17,23 +17,23 @@ function tmpl($api, $cmp, $slotset, $ctx) { $cmp.showStandard ? api_fragment(0, [api_slot("slotname1", stc0, stc1, $slotset)], 0) : $cmp.showVariant - ? api_fragment( - 0, - [ - api_slot( - "slotname1", - { - attrs: stc2, - key: 2, - slotData: $cmp.slot1VariantData, - }, - stc1, - $slotset - ), - ], - 0 - ) - : null, + ? api_fragment( + 0, + [ + api_slot( + "slotname1", + { + attrs: stc2, + key: 2, + slotData: $cmp.slot1VariantData, + }, + stc1, + $slotset + ), + ], + 0 + ) + : null, ]; /*LWC compiler vX.X.X*/ } diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/scoped-slots/if-block/valid/same-slot-types/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/scoped-slots/if-block/valid/same-slot-types/expected.js index 857a72d76d..7140a9c466 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/scoped-slots/if-block/valid/same-slot-types/expected.js +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/scoped-slots/if-block/valid/same-slot-types/expected.js @@ -26,23 +26,23 @@ function tmpl($api, $cmp, $slotset, $ctx) { 0 ) : $cmp.showVariant - ? api_fragment( - 0, - [ - api_slot( - "slotname1", - { - attrs: stc0, - key: 2, - slotData: $cmp.slot1VariantData, - }, - stc1, - $slotset - ), - ], - 0 - ) - : null, + ? api_fragment( + 0, + [ + api_slot( + "slotname1", + { + attrs: stc0, + key: 2, + slotData: $cmp.slot1VariantData, + }, + stc1, + $slotset + ), + ], + 0 + ) + : null, ]; /*LWC compiler vX.X.X*/ } diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/scoped-slots/slot-content-with-directives/valid/if-block/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/scoped-slots/slot-content-with-directives/valid/if-block/expected.js index 22d8bdd610..c11bb8eac9 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/scoped-slots/slot-content-with-directives/valid/if-block/expected.js +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/scoped-slots/slot-content-with-directives/valid/if-block/expected.js @@ -51,18 +51,18 @@ function tmpl($api, $cmp, $slotset, $ctx) { 0 ) : variations.variation2 - ? api_fragment( - 1, - [api_custom_element("x-counter", _xCounter, stc2)], - 0 - ) - : variations.variation2 - ? api_fragment( - 1, - [api_custom_element("x-counter", _xCounter, stc3)], - 0 - ) - : null, + ? api_fragment( + 1, + [api_custom_element("x-counter", _xCounter, stc2)], + 0 + ) + : variations.variation2 + ? api_fragment( + 1, + [api_custom_element("x-counter", _xCounter, stc3)], + 0 + ) + : null, ], 0 ); @@ -82,16 +82,16 @@ function tmpl($api, $cmp, $slotset, $ctx) { 0 ) : variations.variation2 - ? api_fragment( - 5, - [api_custom_element("x-button2", _xButton2, stc5)], - 0 - ) - : api_fragment( - 5, - [api_custom_element("x-button3", _xButton3, stc6)], - 0 - ), + ? api_fragment( + 5, + [api_custom_element("x-button2", _xButton2, stc5)], + 0 + ) + : api_fragment( + 5, + [api_custom_element("x-button3", _xButton3, stc6)], + 0 + ), ], 0 ); diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/static-content/text/else/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/static-content/text/else/expected.js index 4b469ca77d..6677af4e31 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/static-content/text/else/expected.js +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/static-content/text/else/expected.js @@ -57,72 +57,72 @@ function tmpl($api, $cmp, $slotset, $ctx) { 0 ) : $cmp.showElseIf - ? api_fragment( - 0, - [ - api_text(api_dynamic_text($cmp.firstOutterSiblingLwcElseIf)), - api_static_fragment($fragment5, 10, [ - api_static_part(1, null, api_dynamic_text($cmp.solo)), - ]), - api_static_fragment($fragment6, 12, [ - api_static_part( - 1, - null, - api_dynamic_text($cmp.firstInnerSiblingLwcElseIf) - ), - ]), - api_text(api_dynamic_text($cmp.centerOutterSiblingLwcElseIf)), - api_static_fragment($fragment7, 14, [ - api_static_part( - 3, - null, - api_dynamic_text($cmp.secondInnerSiblingLwcElseIf) - ), - ]), - api_static_fragment($fragment8, 16, [ - api_static_part( - 3, - null, - api_dynamic_text($cmp.middleInnerSiblingLwcElseIf) - ), - ]), - api_text(api_dynamic_text($cmp.lastOutterSiblingLwcElseIf)), - ], - 0 - ) - : api_fragment( - 0, - [ - api_text(api_dynamic_text($cmp.firstOutterSiblingLwcElse)), - api_static_fragment($fragment9, 18, [ - api_static_part(1, null, api_dynamic_text($cmp.solo)), - ]), - api_static_fragment($fragment10, 20, [ - api_static_part( - 1, - null, - api_dynamic_text($cmp.firstInnerSiblingLwcElse) - ), - ]), - api_text(api_dynamic_text($cmp.centerOutterSiblingLwcElse)), - api_static_fragment($fragment11, 22, [ - api_static_part( - 3, - null, - api_dynamic_text($cmp.secondInnerSiblingLwcElse) - ), - ]), - api_static_fragment($fragment12, 24, [ - api_static_part( - 3, - null, - api_dynamic_text($cmp.middleInnerSiblingLwcElse) - ), - ]), - api_text(api_dynamic_text($cmp.lastOutterSiblingLwcElse)), - ], - 0 - ), + ? api_fragment( + 0, + [ + api_text(api_dynamic_text($cmp.firstOutterSiblingLwcElseIf)), + api_static_fragment($fragment5, 10, [ + api_static_part(1, null, api_dynamic_text($cmp.solo)), + ]), + api_static_fragment($fragment6, 12, [ + api_static_part( + 1, + null, + api_dynamic_text($cmp.firstInnerSiblingLwcElseIf) + ), + ]), + api_text(api_dynamic_text($cmp.centerOutterSiblingLwcElseIf)), + api_static_fragment($fragment7, 14, [ + api_static_part( + 3, + null, + api_dynamic_text($cmp.secondInnerSiblingLwcElseIf) + ), + ]), + api_static_fragment($fragment8, 16, [ + api_static_part( + 3, + null, + api_dynamic_text($cmp.middleInnerSiblingLwcElseIf) + ), + ]), + api_text(api_dynamic_text($cmp.lastOutterSiblingLwcElseIf)), + ], + 0 + ) + : api_fragment( + 0, + [ + api_text(api_dynamic_text($cmp.firstOutterSiblingLwcElse)), + api_static_fragment($fragment9, 18, [ + api_static_part(1, null, api_dynamic_text($cmp.solo)), + ]), + api_static_fragment($fragment10, 20, [ + api_static_part( + 1, + null, + api_dynamic_text($cmp.firstInnerSiblingLwcElse) + ), + ]), + api_text(api_dynamic_text($cmp.centerOutterSiblingLwcElse)), + api_static_fragment($fragment11, 22, [ + api_static_part( + 3, + null, + api_dynamic_text($cmp.secondInnerSiblingLwcElse) + ), + ]), + api_static_fragment($fragment12, 24, [ + api_static_part( + 3, + null, + api_dynamic_text($cmp.middleInnerSiblingLwcElse) + ), + ]), + api_text(api_dynamic_text($cmp.lastOutterSiblingLwcElse)), + ], + 0 + ), ]; /*LWC compiler vX.X.X*/ } diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/static-content/text/elseif/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/static-content/text/elseif/expected.js index 8523b0395d..51bcb44eb2 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/static-content/text/elseif/expected.js +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/static-content/text/elseif/expected.js @@ -53,40 +53,40 @@ function tmpl($api, $cmp, $slotset, $ctx) { 0 ) : $cmp.showElseIf - ? api_fragment( - 0, - [ - api_text(api_dynamic_text($cmp.firstOutterSiblingLwcElseIf)), - api_static_fragment($fragment5, 10, [ - api_static_part(1, null, api_dynamic_text($cmp.solo)), - ]), - api_static_fragment($fragment6, 12, [ - api_static_part( - 1, - null, - api_dynamic_text($cmp.firstInnerSiblingLwcElseIf) - ), - ]), - api_text(api_dynamic_text($cmp.centerOutterSiblingLwcElseIf)), - api_static_fragment($fragment7, 14, [ - api_static_part( - 3, - null, - api_dynamic_text($cmp.secondInnerSiblingLwcElseIf) - ), - ]), - api_static_fragment($fragment8, 16, [ - api_static_part( - 3, - null, - api_dynamic_text($cmp.middleInnerSiblingLwcElseIf) - ), - ]), - api_text(api_dynamic_text($cmp.lastOutterSiblingLwcElseIf)), - ], - 0 - ) - : null, + ? api_fragment( + 0, + [ + api_text(api_dynamic_text($cmp.firstOutterSiblingLwcElseIf)), + api_static_fragment($fragment5, 10, [ + api_static_part(1, null, api_dynamic_text($cmp.solo)), + ]), + api_static_fragment($fragment6, 12, [ + api_static_part( + 1, + null, + api_dynamic_text($cmp.firstInnerSiblingLwcElseIf) + ), + ]), + api_text(api_dynamic_text($cmp.centerOutterSiblingLwcElseIf)), + api_static_fragment($fragment7, 14, [ + api_static_part( + 3, + null, + api_dynamic_text($cmp.secondInnerSiblingLwcElseIf) + ), + ]), + api_static_fragment($fragment8, 16, [ + api_static_part( + 3, + null, + api_dynamic_text($cmp.middleInnerSiblingLwcElseIf) + ), + ]), + api_text(api_dynamic_text($cmp.lastOutterSiblingLwcElseIf)), + ], + 0 + ) + : null, ]; /*LWC compiler vX.X.X*/ } diff --git a/packages/@lwc/template-compiler/src/parser/index.ts b/packages/@lwc/template-compiler/src/parser/index.ts index 8607a41475..dd30ab02b9 100644 --- a/packages/@lwc/template-compiler/src/parser/index.ts +++ b/packages/@lwc/template-compiler/src/parser/index.ts @@ -564,7 +564,7 @@ function getTemplateRoot( ctx.throw( ParserDiagnostics.MULTIPLE_ROOTS_FOUND, [], - duplicateRoot ? ast.sourceLocation(duplicateRoot) : duplicateRoot ?? undefined + duplicateRoot ? ast.sourceLocation(duplicateRoot) : (duplicateRoot ?? undefined) ); } diff --git a/packages/@lwc/template-compiler/src/shared/types.ts b/packages/@lwc/template-compiler/src/shared/types.ts index a58ea87624..2f5adc17e8 100644 --- a/packages/@lwc/template-compiler/src/shared/types.ts +++ b/packages/@lwc/template-compiler/src/shared/types.ts @@ -89,7 +89,7 @@ export interface EventListener extends BaseNode { } export interface Directive< - T extends keyof typeof ElementDirectiveName | keyof typeof RootDirectiveName + T extends keyof typeof ElementDirectiveName | keyof typeof RootDirectiveName, > extends BaseNode { type: 'Directive'; name: T; diff --git a/scripts/tasks/generate-license-files.js b/scripts/tasks/generate-license-files.js index e042d6769d..920c1c1bd8 100644 --- a/scripts/tasks/generate-license-files.js +++ b/scripts/tasks/generate-license-files.js @@ -60,8 +60,7 @@ async function main() { '\n' )}`.trim() + '\n'; - // TODO [#4386]: Prettier v3 returns a promise - add an `await` here - const formattedLicense = prettier.format(newLicense, { + const formattedLicense = await prettier.format(newLicense, { parser: 'markdown', }); diff --git a/yarn.lock b/yarn.lock index f6e733551b..7b5ed01c39 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1015,9 +1015,11 @@ "@lwc/eslint-plugin-lwc-internal@link:./scripts/eslint-plugin": version "0.0.0" + uid "" "@lwc/test-utils-lwc-internals@link:./scripts/test-utils": version "0.0.0" + uid "" "@napi-rs/wasm-runtime@0.2.4": version "0.2.4" @@ -1749,11 +1751,6 @@ resolved "https://registry.yarnpkg.com/@types/parse5/-/parse5-5.0.3.tgz#e7b5aebbac150f8b5fdd4a46e7f0bd8e65e19109" integrity sha512-kUNnecmtkunAoQ3CnjmMkzNU/gtxG8guhi+Fk2U/kOpIKjIMKnXGp4IJCgQJrXSgMsWYimYG4TGjz/UzbGEBTw== -"@types/prettier@^2.7.3": - version "2.7.3" - resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.7.3.tgz#3e51a17e291d01d17d3fc61422015a933af7a08f" - integrity sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA== - "@types/resolve@1.20.2": version "1.20.2" resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-1.20.2.tgz#97d26e00cd4a0423b4af620abecf3e6f442b7975" @@ -8772,10 +8769,10 @@ prettier@2.8.1: resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.1.tgz#4e1fd11c34e2421bc1da9aea9bd8127cd0a35efc" integrity sha512-lqGoSJBQNJidqCHE80vqZJHWHRFoNYsSpP9AjFhlhi9ODCJA541svILes/+/1GM3VaL/abZi7cpFzOpdR9UPKg== -prettier@^2.8.8: - version "2.8.8" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" - integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== +prettier@^3.3.3: + version "3.3.3" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.3.3.tgz#30c54fe0be0d8d12e6ae61dbb10109ea00d53105" + integrity sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew== pretty-format@^29.7.0: version "29.7.0"