Skip to content

Commit

Permalink
fix: test due rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
jodarove committed Apr 10, 2022
1 parent cfdf043 commit 941ce71
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ function tmpl($api, $cmp, $slotset, $ctx) {
api_slot(
"secret-slot",
stc0,
[api_static_fragment($fragment1 || ($fragment1 = $hoisted1()), 2)],
[
api_static_fragment(
$fragment1 || ($fragment1 = $hoisted1()),
"@secret-slot:2"
),
],
$slotset
),
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,18 @@ function tmpl($api, $cmp, $slotset, $ctx) {
api_slot(
"other",
stc1,
[api_static_fragment($fragment1 || ($fragment1 = $hoisted1()), 3)],
[
api_static_fragment(
$fragment1 || ($fragment1 = $hoisted1()),
"@other:3"
),
],
$slotset
),
api_slot(
"",
stc2,
[api_static_fragment($fragment2 || ($fragment2 = $hoisted2()), 6)],
[api_static_fragment($fragment2 || ($fragment2 = $hoisted2()), "@:6")],
$slotset
),
]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function tmpl($api, $cmp, $slotset, $ctx) {
api_slot(
"",
stc1,
[api_static_fragment($fragment2 || ($fragment2 = $hoisted2()), 5)],
[api_static_fragment($fragment2 || ($fragment2 = $hoisted2()), "@:5")],
$slotset
),
]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function tmpl($api, $cmp, $slotset, $ctx) {
api_slot(
"",
stc1,
[api_static_fragment($fragment1 || ($fragment1 = $hoisted1()), 3)],
[api_static_fragment($fragment1 || ($fragment1 = $hoisted1()), "@:3")],
$slotset
),
]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,18 @@ function tmpl($api, $cmp, $slotset, $ctx) {
api_slot(
"",
stc2,
[api_static_fragment($fragment4 || ($fragment4 = $hoisted4()), 10)],
[api_static_fragment($fragment4 || ($fragment4 = $hoisted4()), "@:10")],
$slotset
),
api_slot(
"footer",
stc3,
[api_static_fragment($fragment5 || ($fragment5 = $hoisted5()), 13)],
[
api_static_fragment(
$fragment5 || ($fragment5 = $hoisted5()),
"@footer:13"
),
],
$slotset
),
]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ function tmpl($api, $cmp, $slotset, $ctx) {
api_slot(
"test",
stc1,
[api_static_fragment($fragment1 || ($fragment1 = $hoisted1()), 3)],
[
api_static_fragment(
$fragment1 || ($fragment1 = $hoisted1()),
"@test:3"
),
],
$slotset
),
]),
Expand Down
8 changes: 6 additions & 2 deletions packages/@lwc/template-compiler/src/codegen/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,11 @@ export default class CodeGen {
return expression as t.Expression;
}

genHoistedElement(element: Element): t.Expression {
genHoistedElement(element: Element, slotParentName?: string): t.Expression {
const key =
slotParentName !== undefined
? `@${slotParentName}:${this.generateKey()}`
: this.generateKey();
const html = serializeStaticElement(element);

this.usedLwcApis.add(PARSE_FRAGMENT_METHOD_NAME);
Expand Down Expand Up @@ -537,7 +541,7 @@ export default class CodeGen {
t.callExpression(t.identifier(`$hoisted${idx}`), [])
)
),
t.literal(this.generateKey()),
t.literal(key),
]);
}
}
2 changes: 1 addition & 1 deletion packages/@lwc/template-compiler/src/codegen/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function transform(codeGen: CodeGen): t.Expression {
res = codeGen.getSlot(element.slotName, databag, defaultSlot);
} else {
res = codeGen.staticNodes.has(element)
? codeGen.genHoistedElement(element)
? codeGen.genHoistedElement(element, slotParentName)
: codeGen.genElement(name, databag, children);
}

Expand Down

0 comments on commit 941ce71

Please sign in to comment.