mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
fix: for resume markers & remove writePrependTo
This commit is contained in:
parent
30b779cd73
commit
e49dd46be9
@ -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");
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user