fix: for resume markers & remove writePrependTo

This commit is contained in:
Michael Rawlings 2024-02-29 17:15:18 -05:00 committed by Dylan Piercey
parent 30b779cd73
commit e49dd46be9
2 changed files with 10 additions and 23 deletions

View File

@ -75,13 +75,22 @@ export default {
enter(tag) {
validateFor(tag);
const { isOnlyChild } = tag.node.extra!;
const tagBody = tag.get("body");
const bodySection = getSection(tagBody);
const { isStateful, singleNodeOptimization, isOnlyChild } =
tag.node.extra!;
if (!isOnlyChild) {
walks.visit(tag, WalkCode.Replace);
walks.enterShallow(tag);
}
if (isOutputHTML()) {
writer.flushBefore(tag);
if (isStateful && !singleNodeOptimization) {
writer.writeTo(tagBody)`${callRuntime(
"markResumeScopeStart",
getScopeIdIdentifier(bodySection),
)}`;
}
}
},
exit(tag) {
@ -273,12 +282,6 @@ const translateHTML = {
let keyExpression: t.Expression | undefined = t.identifier("NOO");
if (isStateful) {
if (!singleNodeOptimization) {
writer.writePrependTo(tagBody)`${callRuntime(
"markResumeScopeStart",
getScopeIdIdentifier(bodySection),
)}`;
}
setRegisterScopeBuilder(tag, (scope: t.Expression) => {
const tempScopeIdentifier =
currentProgramPath.scope.generateUidIdentifier("s");

View File

@ -50,22 +50,6 @@ export function writeTo(path: t.NodePath<any>) {
};
}
export function writePrependTo(path: t.NodePath<any>) {
const section = getSection(path);
return (
strs: TemplateStringsArray,
...exprs: Array<string | t.Expression>
): void => {
const exprsLen = exprs.length;
const writes = getWrites(section);
writes[0] += strs[exprsLen];
for (let i = 0; i < exprsLen; i++) {
writes.unshift(strs[i], exprs[i]);
}
};
}
export function consumeHTML(path: t.NodePath<any>) {
const writes = getWrites(getSection(path));
const result = toTemplateOrStringLiteral(writes);