marko 6.0.0-next.3.30 → 6.0.0-next.3.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/translator/index.js
CHANGED
@@ -1102,6 +1102,7 @@ function startSection(path5) {
|
|
1102
1102
|
params: void 0,
|
1103
1103
|
closures: void 0,
|
1104
1104
|
bindings: void 0,
|
1105
|
+
assignments: void 0,
|
1105
1106
|
content: getContentInfo(path5),
|
1106
1107
|
upstreamExpression: void 0,
|
1107
1108
|
hasAbortSignal: false,
|
@@ -2512,6 +2513,18 @@ function writeHTMLResumeStatements(path5, tagVarIdentifier) {
|
|
2512
2513
|
if (!section) return;
|
2513
2514
|
const allSignals = Array.from(getSignals(section).values());
|
2514
2515
|
const scopeIdIdentifier = getScopeIdIdentifier(section);
|
2516
|
+
forEach(section.assignments, (assignment) => {
|
2517
|
+
let currentSection = section;
|
2518
|
+
while (currentSection !== assignment.section) {
|
2519
|
+
getSerializedScopeProperties(currentSection).set(
|
2520
|
+
import_compiler17.types.stringLiteral("_"),
|
2521
|
+
callRuntime(
|
2522
|
+
"ensureScopeWithId",
|
2523
|
+
getScopeIdIdentifier(currentSection = currentSection.parent)
|
2524
|
+
)
|
2525
|
+
);
|
2526
|
+
}
|
2527
|
+
});
|
2515
2528
|
forEach(section.closures, (closure) => {
|
2516
2529
|
if (isStatefulReferences(closure)) {
|
2517
2530
|
let currentSection = section;
|
@@ -3350,6 +3363,7 @@ function trackAssignment(assignment, binding) {
|
|
3350
3363
|
forEachIdentifier(assignment.node, (id) => {
|
3351
3364
|
if (id.name === binding.name) {
|
3352
3365
|
const extra = id.extra ??= {};
|
3366
|
+
section.assignments = bindingUtil.add(section.assignments, binding);
|
3353
3367
|
extra.assignment = binding;
|
3354
3368
|
extra.section = section;
|
3355
3369
|
}
|
@@ -4202,6 +4216,7 @@ function analyzeAttributeTags(tag) {
|
|
4202
4216
|
if ((0, import_babel_utils16.isAttributeTag)(child)) {
|
4203
4217
|
const name2 = getTagName(child);
|
4204
4218
|
lookup[name2] ||= createAttrTagMeta(name2, [name2]);
|
4219
|
+
(attrTagNodesByName[name2] ||= []).push(child);
|
4205
4220
|
analyzeAttributeTags(child);
|
4206
4221
|
} else {
|
4207
4222
|
const isRepeated = (0, import_babel_utils16.isLoopTag)(child);
|
@@ -8516,7 +8531,8 @@ function translateDOM(tag) {
|
|
8516
8531
|
circular: childFile.opts.filename === file.opts.filename,
|
8517
8532
|
tagSection,
|
8518
8533
|
relativePath,
|
8519
|
-
childScopeBinding
|
8534
|
+
childScopeBinding,
|
8535
|
+
attrTagCallsByTag: void 0
|
8520
8536
|
});
|
8521
8537
|
}
|
8522
8538
|
write2`${(0, import_babel_utils40.importNamed)(file, relativePath, childExports.template, `${tagName}_template`)}`;
|
@@ -8714,7 +8730,38 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
8714
8730
|
}
|
8715
8731
|
let translatedProps = propsToExpression(translatedAttrs.properties);
|
8716
8732
|
if ((0, import_babel_utils40.isAttributeTag)(tag)) {
|
8717
|
-
|
8733
|
+
const attrTagName = getTagName(tag);
|
8734
|
+
const parentTag = tag.parentPath;
|
8735
|
+
const repeated = analyzeAttributeTags(parentTag)?.[attrTagName]?.repeated;
|
8736
|
+
if (repeated) {
|
8737
|
+
let attrTagCallsForTag = (info.attrTagCallsByTag ||= /* @__PURE__ */ new Map()).get(
|
8738
|
+
parentTag
|
8739
|
+
);
|
8740
|
+
if (!attrTagCallsForTag) {
|
8741
|
+
info.attrTagCallsByTag.set(
|
8742
|
+
parentTag,
|
8743
|
+
attrTagCallsForTag = /* @__PURE__ */ new Map()
|
8744
|
+
);
|
8745
|
+
}
|
8746
|
+
const attrTagCall = attrTagCallsForTag.get(attrTagName);
|
8747
|
+
if (attrTagCall) {
|
8748
|
+
attrTagCall.expression = callRuntime(
|
8749
|
+
"attrTags",
|
8750
|
+
attrTagCall.expression,
|
8751
|
+
translatedProps
|
8752
|
+
);
|
8753
|
+
return;
|
8754
|
+
} else {
|
8755
|
+
attrTagCallsForTag.set(
|
8756
|
+
attrTagName,
|
8757
|
+
translatedProps = import_compiler51.types.parenthesizedExpression(
|
8758
|
+
callRuntime("attrTag", translatedProps)
|
8759
|
+
)
|
8760
|
+
);
|
8761
|
+
}
|
8762
|
+
} else {
|
8763
|
+
translatedProps = callRuntime("attrTag", translatedProps);
|
8764
|
+
}
|
8718
8765
|
}
|
8719
8766
|
addValue(
|
8720
8767
|
info.tagSection,
|
@@ -16,6 +16,7 @@ export interface Section {
|
|
16
16
|
params: undefined | Binding;
|
17
17
|
closures: ReferencedBindings;
|
18
18
|
bindings: ReferencedBindings;
|
19
|
+
assignments: ReferencedBindings;
|
19
20
|
upstreamExpression: t.NodeExtra | undefined;
|
20
21
|
hasAbortSignal: boolean;
|
21
22
|
isBranch: boolean;
|
@@ -29,10 +30,6 @@ declare module "@marko/compiler/dist/types" {
|
|
29
30
|
interface ProgramExtra {
|
30
31
|
section?: Section;
|
31
32
|
sections?: Section[];
|
32
|
-
assignments?: [
|
33
|
-
valueSection: Section,
|
34
|
-
assignment: t.NodePath<t.UpdateExpression> | t.NodePath<t.AssignmentExpression>
|
35
|
-
][];
|
36
33
|
}
|
37
34
|
interface MarkoTagBodyExtra {
|
38
35
|
section?: Section;
|