marko 6.0.91 → 6.0.93
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/common/errors.d.ts +3 -0
- package/dist/common/types.d.ts +1 -3
- package/dist/debug/dom.js +54 -19
- package/dist/debug/dom.mjs +54 -19
- package/dist/debug/html.js +33 -13
- package/dist/debug/html.mjs +30 -13
- package/dist/dom/scope.d.ts +1 -1
- package/dist/dom/signals.d.ts +1 -0
- package/dist/dom.d.ts +2 -1
- package/dist/dom.js +93 -82
- package/dist/dom.mjs +93 -82
- package/dist/html/writer.d.ts +4 -3
- package/dist/html.d.ts +1 -0
- package/dist/html.js +17 -6
- package/dist/html.mjs +14 -6
- package/dist/translator/core/html-comment.d.ts +0 -2
- package/dist/translator/core/html-script.d.ts +0 -2
- package/dist/translator/core/html-style.d.ts +0 -2
- package/dist/translator/index.js +271 -367
- package/dist/translator/util/get-defined-binding-expression.d.ts +1 -1
- package/dist/translator/util/references.d.ts +2 -1
- package/dist/translator/util/sections.d.ts +1 -0
- package/dist/translator/util/signals.d.ts +2 -1
- package/dist/translator/util/translate-var.d.ts +2 -0
- package/dist/translator/visitors/program/html.d.ts +1 -0
- package/dist/translator/visitors/tag/native-tag.d.ts +0 -2
- package/package.json +1 -1
package/dist/translator/index.js
CHANGED
|
@@ -1639,6 +1639,7 @@ function startSection(path5) {
|
|
|
1639
1639
|
referencedClosures: void 0,
|
|
1640
1640
|
referencedHoists: void 0,
|
|
1641
1641
|
bindings: void 0,
|
|
1642
|
+
domGetterBindings: /* @__PURE__ */ new Map(),
|
|
1642
1643
|
hoisted: void 0,
|
|
1643
1644
|
isHoistThrough: void 0,
|
|
1644
1645
|
serializeReason: void 0,
|
|
@@ -2591,8 +2592,8 @@ var import_compiler13 = require("@marko/compiler");
|
|
|
2591
2592
|
function normalizeStringExpression(parts) {
|
|
2592
2593
|
const strs = [];
|
|
2593
2594
|
const exprs = [];
|
|
2594
|
-
let curStr =
|
|
2595
|
-
for (let i =
|
|
2595
|
+
let curStr = "";
|
|
2596
|
+
for (let i = 0; i < parts.length; i++) {
|
|
2596
2597
|
let content = parts[i];
|
|
2597
2598
|
if (typeof content === "object") {
|
|
2598
2599
|
if (import_compiler13.types.isStringLiteral(content)) {
|
|
@@ -3276,14 +3277,17 @@ var [getHTMLSectionStatements] = createSectionState(
|
|
|
3276
3277
|
"htmlScopeStatements",
|
|
3277
3278
|
() => []
|
|
3278
3279
|
);
|
|
3279
|
-
var [
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3280
|
+
var [getBindingGetterIdMap] = createSectionState(
|
|
3281
|
+
"bindingGetterIdMap",
|
|
3282
|
+
() => /* @__PURE__ */ new Map()
|
|
3283
|
+
);
|
|
3284
|
+
function getBindingGetterIdentifier(binding) {
|
|
3285
|
+
const idsMap = getBindingGetterIdMap(binding.section);
|
|
3286
|
+
let identifier = idsMap.get(binding);
|
|
3283
3287
|
if (!identifier) {
|
|
3284
3288
|
idsMap.set(
|
|
3285
|
-
|
|
3286
|
-
identifier = generateUidIdentifier(`get${
|
|
3289
|
+
binding,
|
|
3290
|
+
identifier = generateUidIdentifier(`get${binding.name}`)
|
|
3287
3291
|
);
|
|
3288
3292
|
}
|
|
3289
3293
|
return identifier;
|
|
@@ -3392,7 +3396,8 @@ function getSignalFn(signal) {
|
|
|
3392
3396
|
const isIntersection = Array.isArray(binding);
|
|
3393
3397
|
const isBinding = binding && !isIntersection;
|
|
3394
3398
|
const isValue = isBinding && binding.section === section;
|
|
3395
|
-
|
|
3399
|
+
const assertsHoists = isValue && binding.hoists.size && !isOptimize();
|
|
3400
|
+
if (isBinding && (signal.renderReferencedBindings || assertsHoists || binding.aliases.size || binding.propertyAliases.size)) {
|
|
3396
3401
|
const valueParam = import_compiler22.types.identifier(binding.name);
|
|
3397
3402
|
if (binding.loc) {
|
|
3398
3403
|
valueParam.loc = binding.loc;
|
|
@@ -3465,6 +3470,13 @@ function getSignalFn(signal) {
|
|
|
3465
3470
|
)
|
|
3466
3471
|
);
|
|
3467
3472
|
}
|
|
3473
|
+
if (assertsHoists) {
|
|
3474
|
+
signal.render.push(
|
|
3475
|
+
import_compiler22.types.expressionStatement(
|
|
3476
|
+
callRuntime("_assert_hoist", import_compiler22.types.identifier(binding.name))
|
|
3477
|
+
)
|
|
3478
|
+
);
|
|
3479
|
+
}
|
|
3468
3480
|
}
|
|
3469
3481
|
for (const value of signal.values) {
|
|
3470
3482
|
if (signalHasStatements(value.signal)) {
|
|
@@ -3740,6 +3752,7 @@ function getRegisterUID(section, name2) {
|
|
|
3740
3752
|
function writeSignals(section) {
|
|
3741
3753
|
const seen = /* @__PURE__ */ new Set();
|
|
3742
3754
|
writeHoists(section);
|
|
3755
|
+
writeDomGetters(section);
|
|
3743
3756
|
for (const signal of getSignals(section).values()) {
|
|
3744
3757
|
writeSignal(signal);
|
|
3745
3758
|
}
|
|
@@ -3813,6 +3826,24 @@ function writeSignals(section) {
|
|
|
3813
3826
|
(0, import_babel_utils15.getProgram)().node.body.push(...signalStatements);
|
|
3814
3827
|
}
|
|
3815
3828
|
}
|
|
3829
|
+
function writeDomGetters(section) {
|
|
3830
|
+
for (const [binding, registerId] of section.domGetterBindings) {
|
|
3831
|
+
(0, import_babel_utils15.getProgram)().node.body.push(
|
|
3832
|
+
import_compiler22.types.variableDeclaration("const", [
|
|
3833
|
+
import_compiler22.types.variableDeclarator(
|
|
3834
|
+
getBindingGetterIdentifier(binding),
|
|
3835
|
+
callRuntime(
|
|
3836
|
+
"_el",
|
|
3837
|
+
import_compiler22.types.stringLiteral(registerId),
|
|
3838
|
+
import_compiler22.types.stringLiteral(
|
|
3839
|
+
getAccessorPrefix().Getter + getScopeAccessorLiteral(binding).value
|
|
3840
|
+
)
|
|
3841
|
+
)
|
|
3842
|
+
)
|
|
3843
|
+
])
|
|
3844
|
+
);
|
|
3845
|
+
}
|
|
3846
|
+
}
|
|
3816
3847
|
function writeHoists(section) {
|
|
3817
3848
|
forEach(section.hoisted, (binding) => {
|
|
3818
3849
|
for (const hoistedBinding of binding.hoists.values()) {
|
|
@@ -3829,7 +3860,7 @@ function writeHoists(section) {
|
|
|
3829
3860
|
}
|
|
3830
3861
|
currentSection = parentSection;
|
|
3831
3862
|
}
|
|
3832
|
-
const hoistIdentifier =
|
|
3863
|
+
const hoistIdentifier = getBindingGetterIdentifier(hoistedBinding);
|
|
3833
3864
|
(0, import_babel_utils15.getProgram)().node.body.push(
|
|
3834
3865
|
import_compiler22.types.variableDeclaration("const", [
|
|
3835
3866
|
import_compiler22.types.variableDeclarator(
|
|
@@ -3967,66 +3998,6 @@ function writeHTMLResumeStatements(path5) {
|
|
|
3967
3998
|
}
|
|
3968
3999
|
}
|
|
3969
4000
|
});
|
|
3970
|
-
const sectionDynamicSubscribers = /* @__PURE__ */ new Set();
|
|
3971
|
-
forEach(section.hoisted, (binding) => {
|
|
3972
|
-
for (const hoistedBinding of binding.hoists.values()) {
|
|
3973
|
-
if (hoistedBinding.downstreamExpressions.size) {
|
|
3974
|
-
getHTMLSectionStatements(hoistedBinding.section).push(
|
|
3975
|
-
import_compiler22.types.variableDeclaration("const", [
|
|
3976
|
-
import_compiler22.types.variableDeclarator(
|
|
3977
|
-
import_compiler22.types.identifier(hoistedBinding.name),
|
|
3978
|
-
callRuntime(
|
|
3979
|
-
"_hoist",
|
|
3980
|
-
getScopeIdIdentifier(hoistedBinding.section),
|
|
3981
|
-
import_compiler22.types.stringLiteral(
|
|
3982
|
-
getResumeRegisterId(
|
|
3983
|
-
hoistedBinding.section,
|
|
3984
|
-
hoistedBinding,
|
|
3985
|
-
"hoist"
|
|
3986
|
-
)
|
|
3987
|
-
)
|
|
3988
|
-
)
|
|
3989
|
-
)
|
|
3990
|
-
])
|
|
3991
|
-
);
|
|
3992
|
-
}
|
|
3993
|
-
let currentSection = section;
|
|
3994
|
-
while (currentSection && currentSection !== hoistedBinding.section) {
|
|
3995
|
-
const parentSection = currentSection.parent;
|
|
3996
|
-
if (!currentSection.sectionAccessor && !sectionDynamicSubscribers.has(currentSection)) {
|
|
3997
|
-
const subscribersIdentifier = generateUidIdentifier(
|
|
3998
|
-
`${currentSection.name}__subscribers`
|
|
3999
|
-
);
|
|
4000
|
-
sectionDynamicSubscribers.add(currentSection);
|
|
4001
|
-
getHTMLSectionStatements(parentSection).push(
|
|
4002
|
-
import_compiler22.types.variableDeclaration("const", [
|
|
4003
|
-
import_compiler22.types.variableDeclarator(
|
|
4004
|
-
subscribersIdentifier,
|
|
4005
|
-
import_compiler22.types.newExpression(import_compiler22.types.identifier("Set"), [])
|
|
4006
|
-
)
|
|
4007
|
-
])
|
|
4008
|
-
);
|
|
4009
|
-
addWriteScopeBuilder(
|
|
4010
|
-
currentSection,
|
|
4011
|
-
(expr) => callRuntime("_subscribe", subscribersIdentifier, expr)
|
|
4012
|
-
);
|
|
4013
|
-
setSerializedValue(
|
|
4014
|
-
parentSection,
|
|
4015
|
-
getSectionInstancesAccessor(currentSection),
|
|
4016
|
-
subscribersIdentifier
|
|
4017
|
-
);
|
|
4018
|
-
}
|
|
4019
|
-
currentSection = parentSection;
|
|
4020
|
-
}
|
|
4021
|
-
}
|
|
4022
|
-
if (binding.hoists.size && binding.type !== 0 /* dom */) {
|
|
4023
|
-
setBindingSerializedValue(
|
|
4024
|
-
section,
|
|
4025
|
-
binding,
|
|
4026
|
-
getDeclaredBindingExpression(binding)
|
|
4027
|
-
);
|
|
4028
|
-
}
|
|
4029
|
-
});
|
|
4030
4001
|
for (let i = allSignals.length; i--; ) {
|
|
4031
4002
|
if (allSignals[i].effect.length) {
|
|
4032
4003
|
const signalRefs = allSignals[i].referencedBindings;
|
|
@@ -4149,6 +4120,17 @@ function writeHTMLResumeStatements(path5) {
|
|
|
4149
4120
|
...additionalStatements
|
|
4150
4121
|
);
|
|
4151
4122
|
}
|
|
4123
|
+
if (debug) {
|
|
4124
|
+
forEach(section.bindings, (binding) => {
|
|
4125
|
+
if (binding.hoists.size && binding.type !== 0 /* dom */) {
|
|
4126
|
+
body.push(
|
|
4127
|
+
import_compiler22.types.expressionStatement(
|
|
4128
|
+
callRuntime("_assert_hoist", import_compiler22.types.identifier(binding.name))
|
|
4129
|
+
)
|
|
4130
|
+
);
|
|
4131
|
+
}
|
|
4132
|
+
});
|
|
4133
|
+
}
|
|
4152
4134
|
const returnIdentifier = getSectionReturnValueIdentifier(section);
|
|
4153
4135
|
if (returnIdentifier !== void 0) {
|
|
4154
4136
|
body.push(import_compiler22.types.returnStatement(returnIdentifier));
|
|
@@ -4166,9 +4148,19 @@ function replaceEffectNode(node) {
|
|
|
4166
4148
|
function replaceBindingReadNode(node) {
|
|
4167
4149
|
switch (node.type) {
|
|
4168
4150
|
case "Identifier":
|
|
4169
|
-
case "MemberExpression":
|
|
4151
|
+
case "MemberExpression":
|
|
4152
|
+
case "OptionalMemberExpression": {
|
|
4170
4153
|
return getReadReplacement(node);
|
|
4171
4154
|
}
|
|
4155
|
+
case "CallExpression": {
|
|
4156
|
+
const { extra } = node.callee;
|
|
4157
|
+
const binding = extra?.read?.binding;
|
|
4158
|
+
if (binding?.type === 0 /* dom */) {
|
|
4159
|
+
const replacement = createScopeReadExpression(extra.section, binding);
|
|
4160
|
+
return isOptimize() ? replacement : callRuntime("_el_read", replacement);
|
|
4161
|
+
}
|
|
4162
|
+
break;
|
|
4163
|
+
}
|
|
4172
4164
|
}
|
|
4173
4165
|
}
|
|
4174
4166
|
var updateExpressions = /* @__PURE__ */ new WeakSet();
|
|
@@ -4508,6 +4500,70 @@ function getTemplateContentName() {
|
|
|
4508
4500
|
}
|
|
4509
4501
|
var html_default = {
|
|
4510
4502
|
translate: {
|
|
4503
|
+
enter() {
|
|
4504
|
+
forEachSection((section) => {
|
|
4505
|
+
const sectionDynamicSubscribers = /* @__PURE__ */ new Set();
|
|
4506
|
+
forEach(section.hoisted, (binding) => {
|
|
4507
|
+
for (const hoistedBinding of binding.hoists.values()) {
|
|
4508
|
+
if (hoistedBinding.downstreamExpressions.size) {
|
|
4509
|
+
getHTMLSectionStatements(hoistedBinding.section).push(
|
|
4510
|
+
import_compiler24.types.variableDeclaration("const", [
|
|
4511
|
+
import_compiler24.types.variableDeclarator(
|
|
4512
|
+
import_compiler24.types.identifier(hoistedBinding.name),
|
|
4513
|
+
callRuntime(
|
|
4514
|
+
"_hoist",
|
|
4515
|
+
getScopeIdIdentifier(hoistedBinding.section),
|
|
4516
|
+
import_compiler24.types.stringLiteral(
|
|
4517
|
+
getResumeRegisterId(
|
|
4518
|
+
hoistedBinding.section,
|
|
4519
|
+
hoistedBinding,
|
|
4520
|
+
"hoist"
|
|
4521
|
+
)
|
|
4522
|
+
)
|
|
4523
|
+
)
|
|
4524
|
+
)
|
|
4525
|
+
])
|
|
4526
|
+
);
|
|
4527
|
+
}
|
|
4528
|
+
let currentSection = section;
|
|
4529
|
+
while (currentSection && currentSection !== hoistedBinding.section) {
|
|
4530
|
+
const parentSection = currentSection.parent;
|
|
4531
|
+
if (!currentSection.sectionAccessor && !sectionDynamicSubscribers.has(currentSection)) {
|
|
4532
|
+
const subscribersIdentifier = generateUidIdentifier(
|
|
4533
|
+
`${currentSection.name}__subscribers`
|
|
4534
|
+
);
|
|
4535
|
+
sectionDynamicSubscribers.add(currentSection);
|
|
4536
|
+
getHTMLSectionStatements(parentSection).push(
|
|
4537
|
+
import_compiler24.types.variableDeclaration("const", [
|
|
4538
|
+
import_compiler24.types.variableDeclarator(
|
|
4539
|
+
subscribersIdentifier,
|
|
4540
|
+
import_compiler24.types.newExpression(import_compiler24.types.identifier("Set"), [])
|
|
4541
|
+
)
|
|
4542
|
+
])
|
|
4543
|
+
);
|
|
4544
|
+
addWriteScopeBuilder(
|
|
4545
|
+
currentSection,
|
|
4546
|
+
(expr) => callRuntime("_subscribe", subscribersIdentifier, expr)
|
|
4547
|
+
);
|
|
4548
|
+
setSerializedValue(
|
|
4549
|
+
parentSection,
|
|
4550
|
+
getSectionInstancesAccessor(currentSection),
|
|
4551
|
+
subscribersIdentifier
|
|
4552
|
+
);
|
|
4553
|
+
}
|
|
4554
|
+
currentSection = parentSection;
|
|
4555
|
+
}
|
|
4556
|
+
}
|
|
4557
|
+
if (binding.hoists.size && binding.type !== 0 /* dom */) {
|
|
4558
|
+
setBindingSerializedValue(
|
|
4559
|
+
section,
|
|
4560
|
+
binding,
|
|
4561
|
+
getDeclaredBindingExpression(binding)
|
|
4562
|
+
);
|
|
4563
|
+
}
|
|
4564
|
+
});
|
|
4565
|
+
});
|
|
4566
|
+
},
|
|
4511
4567
|
exit(program) {
|
|
4512
4568
|
flushInto(program);
|
|
4513
4569
|
writeHTMLResumeStatements(program);
|
|
@@ -4576,11 +4632,30 @@ function replaceNode(node, container) {
|
|
|
4576
4632
|
function replaceBindingReadNode2(node) {
|
|
4577
4633
|
switch (node.type) {
|
|
4578
4634
|
case "Identifier":
|
|
4579
|
-
case "MemberExpression":
|
|
4635
|
+
case "MemberExpression":
|
|
4636
|
+
case "OptionalMemberExpression": {
|
|
4580
4637
|
const { extra } = node;
|
|
4581
4638
|
if (extra && !(extra.read && !extra.read.binding.declared || extra.binding && !extra.binding.declared)) {
|
|
4582
4639
|
return getReadReplacement(node);
|
|
4583
4640
|
}
|
|
4641
|
+
break;
|
|
4642
|
+
}
|
|
4643
|
+
case "CallExpression": {
|
|
4644
|
+
const binding = node.callee.extra?.read?.binding;
|
|
4645
|
+
if (binding && (binding.type === 6 /* hoist */ || binding.type === 0 /* dom */)) {
|
|
4646
|
+
return import_compiler24.types.callExpression(
|
|
4647
|
+
import_compiler24.types.arrowFunctionExpression(
|
|
4648
|
+
[import_compiler24.types.cloneNode(node.callee)],
|
|
4649
|
+
node
|
|
4650
|
+
),
|
|
4651
|
+
[
|
|
4652
|
+
importRuntime(
|
|
4653
|
+
binding.type === 0 /* dom */ ? "_el_read_error" : "_hoist_read_error"
|
|
4654
|
+
)
|
|
4655
|
+
]
|
|
4656
|
+
);
|
|
4657
|
+
}
|
|
4658
|
+
break;
|
|
4584
4659
|
}
|
|
4585
4660
|
}
|
|
4586
4661
|
}
|
|
@@ -4781,20 +4856,19 @@ function getChangeHandler(tag, attr) {
|
|
|
4781
4856
|
changeAttrName,
|
|
4782
4857
|
withPreviousLocation(import_compiler25.types.identifier(changeHandlerId), attr.value)
|
|
4783
4858
|
);
|
|
4784
|
-
} else if (import_compiler25.types.isMemberExpression(attr.value)) {
|
|
4859
|
+
} else if (import_compiler25.types.isMemberExpression(attr.value) || import_compiler25.types.isOptionalMemberExpression(attr.value)) {
|
|
4785
4860
|
const prop = attr.value.property;
|
|
4786
4861
|
if (!import_compiler25.types.isPrivateName(attr.value.property)) {
|
|
4862
|
+
const memberObj = import_compiler25.types.cloneNode(attr.value.object);
|
|
4863
|
+
const memberProp = prop.type === "Identifier" ? withPreviousLocation(import_compiler25.types.identifier(prop.name + "Change"), prop) : import_compiler25.types.binaryExpression(
|
|
4864
|
+
"+",
|
|
4865
|
+
import_compiler25.types.cloneNode(prop),
|
|
4866
|
+
import_compiler25.types.stringLiteral("Change")
|
|
4867
|
+
);
|
|
4868
|
+
const computed = memberProp.type !== "Identifier";
|
|
4787
4869
|
return import_compiler25.types.markoAttribute(
|
|
4788
4870
|
changeAttrName,
|
|
4789
|
-
import_compiler25.types.memberExpression(
|
|
4790
|
-
import_compiler25.types.cloneNode(attr.value.object),
|
|
4791
|
-
prop.type === "Identifier" ? withPreviousLocation(import_compiler25.types.identifier(prop.name + "Change"), prop) : import_compiler25.types.binaryExpression(
|
|
4792
|
-
"+",
|
|
4793
|
-
import_compiler25.types.cloneNode(prop),
|
|
4794
|
-
import_compiler25.types.stringLiteral("Change")
|
|
4795
|
-
),
|
|
4796
|
-
prop.type !== "Identifier"
|
|
4797
|
-
)
|
|
4871
|
+
attr.value.optional ? import_compiler25.types.optionalMemberExpression(memberObj, memberProp, computed, true) : import_compiler25.types.memberExpression(memberObj, memberProp, computed)
|
|
4798
4872
|
);
|
|
4799
4873
|
}
|
|
4800
4874
|
}
|
|
@@ -5012,6 +5086,9 @@ var program_default = {
|
|
|
5012
5086
|
program.skip();
|
|
5013
5087
|
return;
|
|
5014
5088
|
}
|
|
5089
|
+
if (isOutputHTML()) {
|
|
5090
|
+
html_default.translate.enter();
|
|
5091
|
+
}
|
|
5015
5092
|
},
|
|
5016
5093
|
exit(program) {
|
|
5017
5094
|
if (isOutputHTML()) {
|
|
@@ -5257,6 +5334,27 @@ function translateVar(tag, initialValue, kind = "const") {
|
|
|
5257
5334
|
import_compiler29.types.variableDeclaration(kind, [import_compiler29.types.variableDeclarator(tagVar, initialValue)])
|
|
5258
5335
|
);
|
|
5259
5336
|
}
|
|
5337
|
+
function translateDomVar(tag, binding) {
|
|
5338
|
+
if (binding && tag.node.var) {
|
|
5339
|
+
const tagSection = getSection(tag);
|
|
5340
|
+
const registerId = tagSection.domGetterBindings.get(binding);
|
|
5341
|
+
if (registerId) {
|
|
5342
|
+
tag.parentPath.unshiftContainer(
|
|
5343
|
+
"body",
|
|
5344
|
+
import_compiler29.types.variableDeclaration("const", [
|
|
5345
|
+
import_compiler29.types.variableDeclarator(
|
|
5346
|
+
tag.node.var,
|
|
5347
|
+
callRuntime(
|
|
5348
|
+
"_el",
|
|
5349
|
+
getScopeIdIdentifier(tagSection),
|
|
5350
|
+
import_compiler29.types.stringLiteral(registerId)
|
|
5351
|
+
)
|
|
5352
|
+
)
|
|
5353
|
+
])
|
|
5354
|
+
);
|
|
5355
|
+
}
|
|
5356
|
+
}
|
|
5357
|
+
}
|
|
5260
5358
|
function getDestructurePattern(id) {
|
|
5261
5359
|
let cur = id;
|
|
5262
5360
|
while (cur) {
|
|
@@ -5270,7 +5368,6 @@ function getDestructurePattern(id) {
|
|
|
5270
5368
|
// src/translator/visitors/tag/native-tag.ts
|
|
5271
5369
|
var kNativeTagBinding = Symbol("native tag binding");
|
|
5272
5370
|
var kSkipEndTag = Symbol("skip native tag mark");
|
|
5273
|
-
var kGetterId = Symbol("node getter id");
|
|
5274
5371
|
var kTagContentAttr = Symbol("tag could have dynamic content attribute");
|
|
5275
5372
|
var htmlSelectArgs = /* @__PURE__ */ new WeakMap();
|
|
5276
5373
|
var native_tag_default = {
|
|
@@ -5359,26 +5456,7 @@ var native_tag_default = {
|
|
|
5359
5456
|
!!(node.var || hasEventHandlers),
|
|
5360
5457
|
nodeBinding
|
|
5361
5458
|
);
|
|
5362
|
-
|
|
5363
|
-
for (const ref of tag.scope.getBinding(node.var.name).referencePaths) {
|
|
5364
|
-
const refSection = getOrCreateSection(ref);
|
|
5365
|
-
setReferencesScope(ref);
|
|
5366
|
-
if (isSameOrChildSection(tagSection, refSection)) {
|
|
5367
|
-
addOwnerSerializeReason(refSection, tagSection, true);
|
|
5368
|
-
if (!tagExtra[kGetterId] && !isInvokedFunction(ref)) {
|
|
5369
|
-
tagExtra[kGetterId] = getRegisterUID(
|
|
5370
|
-
tagSection,
|
|
5371
|
-
nodeBinding.name
|
|
5372
|
-
);
|
|
5373
|
-
}
|
|
5374
|
-
} else {
|
|
5375
|
-
trackHoistedReference(
|
|
5376
|
-
ref,
|
|
5377
|
-
nodeBinding
|
|
5378
|
-
);
|
|
5379
|
-
}
|
|
5380
|
-
}
|
|
5381
|
-
}
|
|
5459
|
+
trackDomVarReferences(tag, nodeBinding);
|
|
5382
5460
|
addSerializeExpr(
|
|
5383
5461
|
tagSection,
|
|
5384
5462
|
push(attrExprExtras, tagExtra),
|
|
@@ -5399,17 +5477,7 @@ var native_tag_default = {
|
|
|
5399
5477
|
if (tagExtra.tagNameNullable) {
|
|
5400
5478
|
flushBefore(tag);
|
|
5401
5479
|
}
|
|
5402
|
-
|
|
5403
|
-
const getterId = tagExtra[kGetterId];
|
|
5404
|
-
translateVar(
|
|
5405
|
-
tag,
|
|
5406
|
-
callRuntime(
|
|
5407
|
-
"_el",
|
|
5408
|
-
getterId && getScopeIdIdentifier(tagSection),
|
|
5409
|
-
getterId && import_compiler30.types.stringLiteral(getterId)
|
|
5410
|
-
)
|
|
5411
|
-
);
|
|
5412
|
-
}
|
|
5480
|
+
translateDomVar(tag, nodeBinding);
|
|
5413
5481
|
const visitAccessor = nodeBinding && getScopeAccessorLiteral(nodeBinding);
|
|
5414
5482
|
write`<${tag.node.name}`;
|
|
5415
5483
|
const usedAttrs = getUsedAttrs(tagName, tag.node);
|
|
@@ -5661,59 +5729,6 @@ var native_tag_default = {
|
|
|
5661
5729
|
const tagDef = (0, import_babel_utils20.getTagDef)(tag);
|
|
5662
5730
|
const write = writeTo(tag);
|
|
5663
5731
|
const tagSection = getSection(tag);
|
|
5664
|
-
if (tag.node.var) {
|
|
5665
|
-
const varName = tag.node.var.name;
|
|
5666
|
-
const varBinding = tag.scope.getBinding(varName);
|
|
5667
|
-
const getterId = tagExtra[kGetterId];
|
|
5668
|
-
let getterFnIdentifier;
|
|
5669
|
-
if (getterId) {
|
|
5670
|
-
getterFnIdentifier = generateUidIdentifier(`get_${varName}`);
|
|
5671
|
-
(0, import_babel_utils20.getProgram)().node.body.push(
|
|
5672
|
-
import_compiler30.types.variableDeclaration("const", [
|
|
5673
|
-
import_compiler30.types.variableDeclarator(
|
|
5674
|
-
getterFnIdentifier,
|
|
5675
|
-
callRuntime(
|
|
5676
|
-
"_el",
|
|
5677
|
-
import_compiler30.types.stringLiteral(getterId),
|
|
5678
|
-
import_compiler30.types.stringLiteral(
|
|
5679
|
-
getAccessorPrefix().Getter + getScopeAccessorLiteral(nodeBinding).value
|
|
5680
|
-
)
|
|
5681
|
-
)
|
|
5682
|
-
)
|
|
5683
|
-
])
|
|
5684
|
-
);
|
|
5685
|
-
}
|
|
5686
|
-
for (const reference of varBinding.referencePaths) {
|
|
5687
|
-
const referenceSection = getSection(reference);
|
|
5688
|
-
if (isSameOrChildSection(tagSection, referenceSection)) {
|
|
5689
|
-
if (isInvokedFunction(reference)) {
|
|
5690
|
-
reference.parentPath.replaceWith(
|
|
5691
|
-
import_compiler30.types.expressionStatement(
|
|
5692
|
-
createScopeReadExpression(referenceSection, nodeBinding)
|
|
5693
|
-
)
|
|
5694
|
-
);
|
|
5695
|
-
} else if (getterFnIdentifier) {
|
|
5696
|
-
reference.replaceWith(
|
|
5697
|
-
import_compiler30.types.callExpression(getterFnIdentifier, [
|
|
5698
|
-
getScopeExpression(referenceSection, getSection(tag))
|
|
5699
|
-
])
|
|
5700
|
-
);
|
|
5701
|
-
} else {
|
|
5702
|
-
reference.replaceWith(
|
|
5703
|
-
import_compiler30.types.expressionStatement(
|
|
5704
|
-
import_compiler30.types.memberExpression(
|
|
5705
|
-
getScopeExpression(tagSection, referenceSection),
|
|
5706
|
-
import_compiler30.types.stringLiteral(
|
|
5707
|
-
getAccessorPrefix().Getter + getScopeAccessorLiteral(nodeBinding).value
|
|
5708
|
-
),
|
|
5709
|
-
true
|
|
5710
|
-
)
|
|
5711
|
-
)
|
|
5712
|
-
);
|
|
5713
|
-
}
|
|
5714
|
-
}
|
|
5715
|
-
}
|
|
5716
|
-
}
|
|
5717
5732
|
const visitAccessor = nodeBinding && getScopeAccessorLiteral(nodeBinding);
|
|
5718
5733
|
if (visitAccessor) {
|
|
5719
5734
|
visit(tag, 32 /* Get */);
|
|
@@ -7778,6 +7793,42 @@ function createBinding(name2, type, section, upstreamAlias, property, excludePro
|
|
|
7778
7793
|
getBindings().add(binding);
|
|
7779
7794
|
return binding;
|
|
7780
7795
|
}
|
|
7796
|
+
function trackDomVarReferences(tag, binding) {
|
|
7797
|
+
const tagVar = tag.node.var;
|
|
7798
|
+
if (!tagVar) {
|
|
7799
|
+
return;
|
|
7800
|
+
}
|
|
7801
|
+
if (!import_compiler35.types.isIdentifier(tagVar)) {
|
|
7802
|
+
throw tag.get("var").buildCodeFrameError(
|
|
7803
|
+
"Tag variables on native elements cannot be destructured."
|
|
7804
|
+
);
|
|
7805
|
+
}
|
|
7806
|
+
const babelBinding = tag.scope.getBinding(tagVar.name);
|
|
7807
|
+
const section = getOrCreateSection(tag);
|
|
7808
|
+
if (babelBinding.constantViolations.length) {
|
|
7809
|
+
throw babelBinding.constantViolations[0].buildCodeFrameError(
|
|
7810
|
+
"Tag variables on native elements cannot be assigned to."
|
|
7811
|
+
);
|
|
7812
|
+
}
|
|
7813
|
+
let registerId;
|
|
7814
|
+
for (const ref of babelBinding.referencePaths) {
|
|
7815
|
+
const refSection = getOrCreateSection(ref);
|
|
7816
|
+
setReferencesScope(ref);
|
|
7817
|
+
if (isSameOrChildSection(binding.section, refSection)) {
|
|
7818
|
+
(ref.node.extra ??= {}).read = createRead(binding, void 0);
|
|
7819
|
+
if (!isInvokedFunction(ref)) {
|
|
7820
|
+
section.domGetterBindings.set(
|
|
7821
|
+
binding,
|
|
7822
|
+
registerId ??= getRegisterUID(section, binding.name)
|
|
7823
|
+
);
|
|
7824
|
+
}
|
|
7825
|
+
addOwnerSerializeReason(refSection, section, true);
|
|
7826
|
+
} else {
|
|
7827
|
+
trackHoistedReference(ref, binding);
|
|
7828
|
+
}
|
|
7829
|
+
}
|
|
7830
|
+
return binding;
|
|
7831
|
+
}
|
|
7781
7832
|
function trackVarReferences(tag, type, upstreamAlias) {
|
|
7782
7833
|
const tagVar = tag.node.var;
|
|
7783
7834
|
if (tagVar) {
|
|
@@ -7897,20 +7948,35 @@ function trackHoistedReference(referencePath, binding) {
|
|
|
7897
7948
|
hoistedBinding
|
|
7898
7949
|
);
|
|
7899
7950
|
}
|
|
7951
|
+
function isReferenceHoisted(bindingPath, reference) {
|
|
7952
|
+
const tag = bindingPath.isMarkoTag() ? bindingPath : getMarkoRoot(bindingPath)?.parentPath;
|
|
7953
|
+
if (!tag?.isMarkoTag()) {
|
|
7954
|
+
return false;
|
|
7955
|
+
}
|
|
7956
|
+
const body = tag.parentPath;
|
|
7957
|
+
let cur = reference;
|
|
7958
|
+
while (cur) {
|
|
7959
|
+
if (cur.parentPath === body) {
|
|
7960
|
+
return +tag.key > +cur.key;
|
|
7961
|
+
}
|
|
7962
|
+
cur = cur.parentPath;
|
|
7963
|
+
}
|
|
7964
|
+
return true;
|
|
7965
|
+
}
|
|
7900
7966
|
function trackReferencesForBinding(babelBinding, binding) {
|
|
7901
7967
|
const { referencePaths, constantViolations } = babelBinding;
|
|
7902
|
-
for (const
|
|
7903
|
-
const
|
|
7904
|
-
if (
|
|
7905
|
-
|
|
7906
|
-
|
|
7907
|
-
|
|
7908
|
-
trackReference(referencePath, binding);
|
|
7909
|
-
} else {
|
|
7910
|
-
trackHoistedReference(referencePath, binding);
|
|
7968
|
+
for (const ref of referencePaths) {
|
|
7969
|
+
const refSection = getOrCreateSection(ref);
|
|
7970
|
+
if (isReferenceHoisted(babelBinding.path, ref)) {
|
|
7971
|
+
trackHoistedReference(ref, binding);
|
|
7972
|
+
} else if (binding.type !== 4 /* local */ || refSection !== binding.section) {
|
|
7973
|
+
trackReference(ref, binding);
|
|
7911
7974
|
}
|
|
7912
7975
|
}
|
|
7913
7976
|
for (const ref of constantViolations) {
|
|
7977
|
+
if (isReferenceHoisted(babelBinding.path, ref)) {
|
|
7978
|
+
throw ref.buildCodeFrameError("Cannot assign to hoisted tag variable.");
|
|
7979
|
+
}
|
|
7914
7980
|
if (ref.isUpdateExpression()) {
|
|
7915
7981
|
trackAssignment(ref.get("argument"), binding);
|
|
7916
7982
|
} else if (ref.isAssignmentExpression()) {
|
|
@@ -8077,7 +8143,8 @@ function trackReference(referencePath, binding) {
|
|
|
8077
8143
|
let propPath = binding.name;
|
|
8078
8144
|
while (true) {
|
|
8079
8145
|
const { parent } = root;
|
|
8080
|
-
if (!import_compiler35.types.isMemberExpression(parent))
|
|
8146
|
+
if (!import_compiler35.types.isMemberExpression(parent) && !import_compiler35.types.isOptionalMemberExpression(parent))
|
|
8147
|
+
break;
|
|
8081
8148
|
const prop = getMemberExpressionPropString(parent);
|
|
8082
8149
|
if (prop === void 0) break;
|
|
8083
8150
|
if (reference.upstreamAlias && reference.excludeProperties !== void 0 && !propsUtil.has(reference.excludeProperties, prop)) {
|
|
@@ -8675,10 +8742,23 @@ function getReadReplacement(node) {
|
|
|
8675
8742
|
}
|
|
8676
8743
|
if (binding) {
|
|
8677
8744
|
if (node.type === "Identifier") {
|
|
8678
|
-
if (binding.type ===
|
|
8679
|
-
|
|
8680
|
-
|
|
8681
|
-
|
|
8745
|
+
if (binding.type === 0 /* dom */) {
|
|
8746
|
+
if (binding.section.domGetterBindings.has(binding) && isOutputDOM()) {
|
|
8747
|
+
replacement = import_compiler35.types.callExpression(getBindingGetterIdentifier(binding), [
|
|
8748
|
+
getScopeExpression(node.extra.section, binding.section)
|
|
8749
|
+
]);
|
|
8750
|
+
}
|
|
8751
|
+
} else if (binding.type === 6 /* hoist */) {
|
|
8752
|
+
if (node.extra?.[kIsInvoked]) {
|
|
8753
|
+
if (isOutputDOM()) {
|
|
8754
|
+
replacement = import_compiler35.types.callExpression(
|
|
8755
|
+
getBindingGetterIdentifier(binding),
|
|
8756
|
+
[getScopeExpression(node.extra.section, binding.section)]
|
|
8757
|
+
);
|
|
8758
|
+
}
|
|
8759
|
+
} else {
|
|
8760
|
+
replacement = import_compiler35.types.identifier(binding.name);
|
|
8761
|
+
}
|
|
8682
8762
|
} else if (binding.name !== node.name) {
|
|
8683
8763
|
node.name = binding.name;
|
|
8684
8764
|
}
|
|
@@ -9373,7 +9453,6 @@ function templateElement(value, tail) {
|
|
|
9373
9453
|
|
|
9374
9454
|
// src/translator/core/html-comment.ts
|
|
9375
9455
|
var kNodeBinding = Symbol("comment tag binding");
|
|
9376
|
-
var kGetterId2 = Symbol("node getter id");
|
|
9377
9456
|
var html_comment_default = {
|
|
9378
9457
|
analyze(tag) {
|
|
9379
9458
|
(0, import_babel_utils33.assertNoArgs)(tag);
|
|
@@ -9381,7 +9460,6 @@ var html_comment_default = {
|
|
|
9381
9460
|
(0, import_babel_utils33.assertNoAttributes)(tag);
|
|
9382
9461
|
const tagVar = tag.node.var;
|
|
9383
9462
|
let needsBinding = false;
|
|
9384
|
-
let needsGetter = false;
|
|
9385
9463
|
if (tagVar) {
|
|
9386
9464
|
if (!import_compiler43.types.isIdentifier(tagVar)) {
|
|
9387
9465
|
throw tag.get("var").buildCodeFrameError(
|
|
@@ -9389,12 +9467,6 @@ var html_comment_default = {
|
|
|
9389
9467
|
);
|
|
9390
9468
|
}
|
|
9391
9469
|
needsBinding = true;
|
|
9392
|
-
for (const ref of tag.scope.getBinding(tagVar.name).referencePaths) {
|
|
9393
|
-
if (!isInvokedFunction(ref)) {
|
|
9394
|
-
needsGetter = true;
|
|
9395
|
-
break;
|
|
9396
|
-
}
|
|
9397
|
-
}
|
|
9398
9470
|
}
|
|
9399
9471
|
const referenceNodes = [];
|
|
9400
9472
|
for (const child of tag.get("body").get("body")) {
|
|
@@ -9415,9 +9487,7 @@ var html_comment_default = {
|
|
|
9415
9487
|
0 /* dom */,
|
|
9416
9488
|
tagSection
|
|
9417
9489
|
);
|
|
9418
|
-
|
|
9419
|
-
tagExtra[kGetterId2] = getRegisterUID(tagSection, "comment");
|
|
9420
|
-
}
|
|
9490
|
+
trackDomVarReferences(tag, nodeBinding);
|
|
9421
9491
|
addSerializeExpr(tagSection, !!tagVar || tagExtra, nodeBinding);
|
|
9422
9492
|
}
|
|
9423
9493
|
tag.skip();
|
|
@@ -9426,54 +9496,8 @@ var html_comment_default = {
|
|
|
9426
9496
|
enter(tag) {
|
|
9427
9497
|
const tagExtra = tag.node.extra;
|
|
9428
9498
|
const nodeBinding = tagExtra[kNodeBinding];
|
|
9429
|
-
|
|
9430
|
-
|
|
9431
|
-
const getterId = tagExtra[kGetterId2];
|
|
9432
|
-
if (isOutputHTML()) {
|
|
9433
|
-
translateVar(
|
|
9434
|
-
tag,
|
|
9435
|
-
callRuntime(
|
|
9436
|
-
"_el",
|
|
9437
|
-
getterId && getScopeIdIdentifier(getSection(tag)),
|
|
9438
|
-
getterId && import_compiler43.types.stringLiteral(getterId)
|
|
9439
|
-
)
|
|
9440
|
-
);
|
|
9441
|
-
} else {
|
|
9442
|
-
const varName = tag.node.var.name;
|
|
9443
|
-
const references = tag.scope.getBinding(varName).referencePaths;
|
|
9444
|
-
let getterFnIdentifier;
|
|
9445
|
-
if (getterId) {
|
|
9446
|
-
getterFnIdentifier = generateUidIdentifier(`get_${varName}`);
|
|
9447
|
-
(0, import_babel_utils33.getProgram)().node.body.push(
|
|
9448
|
-
import_compiler43.types.variableDeclaration("const", [
|
|
9449
|
-
import_compiler43.types.variableDeclarator(
|
|
9450
|
-
getterFnIdentifier,
|
|
9451
|
-
callRuntime(
|
|
9452
|
-
"_el",
|
|
9453
|
-
import_compiler43.types.stringLiteral(getterId),
|
|
9454
|
-
getScopeAccessorLiteral(nodeBinding)
|
|
9455
|
-
)
|
|
9456
|
-
)
|
|
9457
|
-
])
|
|
9458
|
-
);
|
|
9459
|
-
}
|
|
9460
|
-
for (const reference of references) {
|
|
9461
|
-
const referenceSection = getSection(reference);
|
|
9462
|
-
if (isInvokedFunction(reference)) {
|
|
9463
|
-
reference.parentPath.replaceWith(
|
|
9464
|
-
import_compiler43.types.expressionStatement(
|
|
9465
|
-
createScopeReadExpression(referenceSection, nodeBinding)
|
|
9466
|
-
)
|
|
9467
|
-
);
|
|
9468
|
-
} else if (getterFnIdentifier) {
|
|
9469
|
-
reference.replaceWith(
|
|
9470
|
-
import_compiler43.types.callExpression(getterFnIdentifier, [
|
|
9471
|
-
getScopeExpression(referenceSection, getSection(tag))
|
|
9472
|
-
])
|
|
9473
|
-
);
|
|
9474
|
-
}
|
|
9475
|
-
}
|
|
9476
|
-
}
|
|
9499
|
+
if (isOutputHTML()) {
|
|
9500
|
+
translateDomVar(tag, nodeBinding);
|
|
9477
9501
|
}
|
|
9478
9502
|
if (nodeBinding) {
|
|
9479
9503
|
visit(tag, 32 /* Get */);
|
|
@@ -9545,7 +9569,6 @@ var html_comment_default = {
|
|
|
9545
9569
|
var import_compiler44 = require("@marko/compiler");
|
|
9546
9570
|
var import_babel_utils34 = require("@marko/compiler/babel-utils");
|
|
9547
9571
|
var kNodeBinding2 = Symbol("script tag node binding");
|
|
9548
|
-
var kGetterId3 = Symbol("node getter id");
|
|
9549
9572
|
var html_script_default = {
|
|
9550
9573
|
analyze(tag) {
|
|
9551
9574
|
(0, import_babel_utils34.assertNoArgs)(tag);
|
|
@@ -9627,25 +9650,12 @@ var html_script_default = {
|
|
|
9627
9650
|
)
|
|
9628
9651
|
);
|
|
9629
9652
|
}
|
|
9653
|
+
trackDomVarReferences(tag, nodeBinding);
|
|
9630
9654
|
addSerializeExpr(
|
|
9631
9655
|
tagSection,
|
|
9632
9656
|
!!(node.var || hasEventHandlers),
|
|
9633
9657
|
nodeBinding
|
|
9634
9658
|
);
|
|
9635
|
-
if (node.var) {
|
|
9636
|
-
for (const ref of tag.scope.getBinding(node.var.name).referencePaths) {
|
|
9637
|
-
const refSection = getOrCreateSection(ref);
|
|
9638
|
-
setReferencesScope(ref);
|
|
9639
|
-
if (isSameOrChildSection(tagSection, refSection)) {
|
|
9640
|
-
addOwnerSerializeReason(refSection, tagSection, true);
|
|
9641
|
-
if (!tagExtra[kGetterId3] && !isInvokedFunction(ref)) {
|
|
9642
|
-
tagExtra[kGetterId3] = getRegisterUID(tagSection, "#script");
|
|
9643
|
-
}
|
|
9644
|
-
} else {
|
|
9645
|
-
trackHoistedReference(ref, nodeBinding);
|
|
9646
|
-
}
|
|
9647
|
-
}
|
|
9648
|
-
}
|
|
9649
9659
|
addSerializeExpr(tagSection, push(exprExtras, tagExtra), nodeBinding);
|
|
9650
9660
|
}
|
|
9651
9661
|
},
|
|
@@ -9656,54 +9666,8 @@ var html_script_default = {
|
|
|
9656
9666
|
const isHTML = isOutputHTML();
|
|
9657
9667
|
const write = writeTo(tag);
|
|
9658
9668
|
const tagSection = getSection(tag);
|
|
9659
|
-
|
|
9660
|
-
|
|
9661
|
-
const getterId = tagExtra[kGetterId3];
|
|
9662
|
-
if (isHTML) {
|
|
9663
|
-
translateVar(
|
|
9664
|
-
tag,
|
|
9665
|
-
callRuntime(
|
|
9666
|
-
"_el",
|
|
9667
|
-
getterId && getScopeIdIdentifier(tagSection),
|
|
9668
|
-
getterId && import_compiler44.types.stringLiteral(getterId)
|
|
9669
|
-
)
|
|
9670
|
-
);
|
|
9671
|
-
} else {
|
|
9672
|
-
const varName = tag.node.var.name;
|
|
9673
|
-
const references = tag.scope.getBinding(varName).referencePaths;
|
|
9674
|
-
let getterFnIdentifier;
|
|
9675
|
-
if (getterId) {
|
|
9676
|
-
getterFnIdentifier = generateUidIdentifier(`get_${varName}`);
|
|
9677
|
-
(0, import_babel_utils34.getProgram)().node.body.push(
|
|
9678
|
-
import_compiler44.types.variableDeclaration("const", [
|
|
9679
|
-
import_compiler44.types.variableDeclarator(
|
|
9680
|
-
getterFnIdentifier,
|
|
9681
|
-
callRuntime(
|
|
9682
|
-
"_el",
|
|
9683
|
-
import_compiler44.types.stringLiteral(getterId),
|
|
9684
|
-
getScopeAccessorLiteral(nodeBinding)
|
|
9685
|
-
)
|
|
9686
|
-
)
|
|
9687
|
-
])
|
|
9688
|
-
);
|
|
9689
|
-
}
|
|
9690
|
-
for (const reference of references) {
|
|
9691
|
-
const referenceSection = getSection(reference);
|
|
9692
|
-
if (isInvokedFunction(reference)) {
|
|
9693
|
-
reference.parentPath.replaceWith(
|
|
9694
|
-
import_compiler44.types.expressionStatement(
|
|
9695
|
-
createScopeReadExpression(referenceSection, nodeBinding)
|
|
9696
|
-
)
|
|
9697
|
-
);
|
|
9698
|
-
} else if (getterFnIdentifier) {
|
|
9699
|
-
reference.replaceWith(
|
|
9700
|
-
import_compiler44.types.callExpression(getterFnIdentifier, [
|
|
9701
|
-
getScopeExpression(referenceSection, getSection(tag))
|
|
9702
|
-
])
|
|
9703
|
-
);
|
|
9704
|
-
}
|
|
9705
|
-
}
|
|
9706
|
-
}
|
|
9669
|
+
if (isHTML) {
|
|
9670
|
+
translateDomVar(tag, nodeBinding);
|
|
9707
9671
|
}
|
|
9708
9672
|
const visitAccessor = nodeBinding && getScopeAccessorLiteral(nodeBinding);
|
|
9709
9673
|
if (visitAccessor) {
|
|
@@ -9850,7 +9814,7 @@ var html_script_default = {
|
|
|
9850
9814
|
} else {
|
|
9851
9815
|
const textLiteral = bodyToTextLiteral(tag.node.body);
|
|
9852
9816
|
if (import_compiler44.types.isStringLiteral(textLiteral)) {
|
|
9853
|
-
write`${textLiteral
|
|
9817
|
+
write`${textLiteral}`;
|
|
9854
9818
|
} else {
|
|
9855
9819
|
addStatement(
|
|
9856
9820
|
"render",
|
|
@@ -9950,7 +9914,6 @@ function getUsedAttrs2(tag) {
|
|
|
9950
9914
|
var import_compiler45 = require("@marko/compiler");
|
|
9951
9915
|
var import_babel_utils35 = require("@marko/compiler/babel-utils");
|
|
9952
9916
|
var kNodeBinding3 = Symbol("style tag node binding");
|
|
9953
|
-
var kGetterId4 = Symbol("node getter id");
|
|
9954
9917
|
var html_style_default = {
|
|
9955
9918
|
analyze(tag) {
|
|
9956
9919
|
(0, import_babel_utils35.assertNoArgs)(tag);
|
|
@@ -10032,25 +9995,12 @@ var html_style_default = {
|
|
|
10032
9995
|
)
|
|
10033
9996
|
);
|
|
10034
9997
|
}
|
|
9998
|
+
trackDomVarReferences(tag, nodeBinding);
|
|
10035
9999
|
addSerializeExpr(
|
|
10036
10000
|
tagSection,
|
|
10037
10001
|
!!(node.var || hasEventHandlers),
|
|
10038
10002
|
nodeBinding
|
|
10039
10003
|
);
|
|
10040
|
-
if (node.var) {
|
|
10041
|
-
for (const ref of tag.scope.getBinding(node.var.name).referencePaths) {
|
|
10042
|
-
const refSection = getOrCreateSection(ref);
|
|
10043
|
-
setReferencesScope(ref);
|
|
10044
|
-
if (isSameOrChildSection(tagSection, refSection)) {
|
|
10045
|
-
addOwnerSerializeReason(refSection, tagSection, true);
|
|
10046
|
-
if (!tagExtra[kGetterId4] && !isInvokedFunction(ref)) {
|
|
10047
|
-
tagExtra[kGetterId4] = getRegisterUID(tagSection, "#style");
|
|
10048
|
-
}
|
|
10049
|
-
} else {
|
|
10050
|
-
trackHoistedReference(ref, nodeBinding);
|
|
10051
|
-
}
|
|
10052
|
-
}
|
|
10053
|
-
}
|
|
10054
10004
|
addSerializeExpr(tagSection, push(exprExtras, tagExtra), nodeBinding);
|
|
10055
10005
|
}
|
|
10056
10006
|
},
|
|
@@ -10061,54 +10011,8 @@ var html_style_default = {
|
|
|
10061
10011
|
const isHTML = isOutputHTML();
|
|
10062
10012
|
const write = writeTo(tag);
|
|
10063
10013
|
const tagSection = getSection(tag);
|
|
10064
|
-
|
|
10065
|
-
|
|
10066
|
-
const getterId = tagExtra[kGetterId4];
|
|
10067
|
-
if (isHTML) {
|
|
10068
|
-
translateVar(
|
|
10069
|
-
tag,
|
|
10070
|
-
callRuntime(
|
|
10071
|
-
"_el",
|
|
10072
|
-
getterId && getScopeIdIdentifier(tagSection),
|
|
10073
|
-
getterId && import_compiler45.types.stringLiteral(getterId)
|
|
10074
|
-
)
|
|
10075
|
-
);
|
|
10076
|
-
} else {
|
|
10077
|
-
const varName = tag.node.var.name;
|
|
10078
|
-
const references = tag.scope.getBinding(varName).referencePaths;
|
|
10079
|
-
let getterFnIdentifier;
|
|
10080
|
-
if (getterId) {
|
|
10081
|
-
getterFnIdentifier = generateUidIdentifier(`get_${varName}`);
|
|
10082
|
-
(0, import_babel_utils35.getProgram)().node.body.push(
|
|
10083
|
-
import_compiler45.types.variableDeclaration("const", [
|
|
10084
|
-
import_compiler45.types.variableDeclarator(
|
|
10085
|
-
getterFnIdentifier,
|
|
10086
|
-
callRuntime(
|
|
10087
|
-
"_el",
|
|
10088
|
-
import_compiler45.types.stringLiteral(getterId),
|
|
10089
|
-
getScopeAccessorLiteral(nodeBinding)
|
|
10090
|
-
)
|
|
10091
|
-
)
|
|
10092
|
-
])
|
|
10093
|
-
);
|
|
10094
|
-
}
|
|
10095
|
-
for (const reference of references) {
|
|
10096
|
-
const referenceSection = getSection(reference);
|
|
10097
|
-
if (isInvokedFunction(reference)) {
|
|
10098
|
-
reference.parentPath.replaceWith(
|
|
10099
|
-
import_compiler45.types.expressionStatement(
|
|
10100
|
-
createScopeReadExpression(referenceSection, nodeBinding)
|
|
10101
|
-
)
|
|
10102
|
-
);
|
|
10103
|
-
} else if (getterFnIdentifier) {
|
|
10104
|
-
reference.replaceWith(
|
|
10105
|
-
import_compiler45.types.callExpression(getterFnIdentifier, [
|
|
10106
|
-
getScopeExpression(referenceSection, getSection(tag))
|
|
10107
|
-
])
|
|
10108
|
-
);
|
|
10109
|
-
}
|
|
10110
|
-
}
|
|
10111
|
-
}
|
|
10014
|
+
if (isHTML) {
|
|
10015
|
+
translateDomVar(tag, nodeBinding);
|
|
10112
10016
|
}
|
|
10113
10017
|
const visitAccessor = nodeBinding && getScopeAccessorLiteral(nodeBinding);
|
|
10114
10018
|
if (visitAccessor) {
|