Skip to content

Commit 4438a7d

Browse files
committed
fix: using incorrect key
1 parent ac1ece6 commit 4438a7d

File tree

5 files changed

+16
-21
lines changed

5 files changed

+16
-21
lines changed

packages/@lwc/engine-core/src/framework/api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ function addVNodeToChildLWC(vnode: VCustomElement) {
5252
}
5353

5454
// [st]atic node
55-
function st(hoisted: Element, html: string, key: Key): VStatic {
55+
function st(elmProto: Element, key: Key): VStatic {
5656
return {
5757
type: VNodeType.Static,
5858
sel: undefined,
5959
key,
6060
elm: undefined,
61-
elmProto: hoisted,
61+
elmProto,
6262
owner: getVMBeingRendered()!,
6363
};
6464
}

packages/@lwc/engine-core/src/framework/rendering.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ function mountStatic(vnode: VStatic, parent: ParentNode, anchor: Node | null) {
222222
}
223223

224224
if (process.env.NODE_ENV !== 'production') {
225-
const isLight = owner.renderMode === RenderMode.Light;
225+
const isLight = renderMode === RenderMode.Light;
226226
patchElementWithRestrictions(elm, { isPortal: false, isLight });
227227
}
228228

@@ -357,7 +357,7 @@ function observeElementChildNodes(elm: Element) {
357357
(elm as any).$domManual$ = true;
358358
}
359359

360-
export function setElementShadowToken(elm: Element, token: string) {
360+
function setElementShadowToken(elm: Element, token: string) {
361361
(elm as any).$shadowToken$ = token;
362362
}
363363

packages/@lwc/engine-core/src/framework/template.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ export interface Template {
5555
stylesheetToken?: string;
5656
/** Render mode for the template. Could be light or undefined (which means it's shadow) */
5757
renderMode?: 'light';
58-
/** Hoisted Fragments */
59-
hoistedFragments?: Node[];
6058
}
6159

6260
export let isUpdatingTemplate: boolean = false;
@@ -127,21 +125,21 @@ export function parseFragment(strings: string[], ...keys: number[]): () => Eleme
127125
const attrToken =
128126
stylesheetToken && shadowMode === ShadowMode.Synthetic ? stylesheetToken : '""';
129127

130-
const genHtmlFragment: string[] = [];
128+
const htmlFragments: string[] = [];
131129
for (let i = 0, n = keys.length; i < n; i++) {
132130
switch (keys[i]) {
133131
case 0:
134-
genHtmlFragment.push(strings[i], classToken);
132+
htmlFragments.push(strings[i], classToken);
135133
break;
136134
case 1:
137-
genHtmlFragment.push(strings[i], attrToken);
135+
htmlFragments.push(strings[i], attrToken);
138136
break;
139137
}
140138
}
141139

142-
genHtmlFragment.push(strings[strings.length - 1]);
140+
htmlFragments.push(strings[strings.length - 1]);
143141

144-
return createFragment(genHtmlFragment.join(''));
142+
return createFragment(htmlFragments.join(''));
145143
};
146144
}
147145

packages/@lwc/template-compiler/src/codegen/codegen.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { NormalizedConfig } from '../config';
1212
import * as t from '../shared/estree';
1313
import {
1414
BaseElement,
15-
BaseParentNode,
1615
ChildNode,
1716
Element,
1817
Expression,
@@ -25,7 +24,6 @@ import {
2524
isBaseElement,
2625
isComment,
2726
isComponent,
28-
isIf,
2927
isPreserveCommentsDirective,
3028
isRenderModeDirective,
3129
isSlot,
@@ -89,7 +87,7 @@ interface Scope {
8987
function getStaticNodes(root: Root): Set<ChildNode> {
9088
const hoistedNodes = new Set<ChildNode>();
9189

92-
function isStaticNode(node: BaseElement, parent: BaseParentNode): boolean {
90+
function isStaticNode(node: BaseElement): boolean {
9391
let result = true;
9492
const {
9593
name: nodeName,
@@ -100,7 +98,6 @@ function getStaticNodes(root: Root): Set<ChildNode> {
10098
listeners,
10199
} = node;
102100

103-
result &&= !isIf(parent); // when parent node is an if, this element output is bound to some component value.
104101
result &&= !isSlot(node); // slot element can't be static.
105102
result &&= !isComponent(node); // components are not static.
106103

@@ -127,9 +124,9 @@ function getStaticNodes(root: Root): Set<ChildNode> {
127124
return result;
128125
}
129126

130-
function collectStaticNodes(node: ChildNode, parent: BaseParentNode) {
127+
function collectStaticNodes(node: ChildNode) {
131128
let childrenAreStatic = true;
132-
let nodeIsStatic = true;
129+
let nodeIsStatic;
133130

134131
if (isText(node)) {
135132
nodeIsStatic = isLiteral(node.value);
@@ -138,12 +135,12 @@ function getStaticNodes(root: Root): Set<ChildNode> {
138135
} else {
139136
// it is ForBlock | If | BaseElement
140137
node.children.forEach((childNode) => {
141-
collectStaticNodes(childNode, node);
138+
collectStaticNodes(childNode);
142139

143140
childrenAreStatic = childrenAreStatic && hoistedNodes.has(childNode);
144141
});
145142

146-
nodeIsStatic = isBaseElement(node) && isStaticNode(node, parent);
143+
nodeIsStatic = isBaseElement(node) && isStaticNode(node);
147144
}
148145

149146
if (nodeIsStatic && childrenAreStatic) {
@@ -155,7 +152,7 @@ function getStaticNodes(root: Root): Set<ChildNode> {
155152
}
156153
}
157154

158-
root.children.forEach((childNode) => collectStaticNodes(childNode, root));
155+
root.children.forEach((childNode) => collectStaticNodes(childNode));
159156

160157
return hoistedNodes;
161158
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { LightningElement } from 'lwc';
22

33
export default class Xlink extends LightningElement {
4-
href = "/foo";
4+
href = '/foo';
55
}

0 commit comments

Comments
 (0)