@marko/compiler 5.39.29 → 5.39.30
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/babel-plugin/parser.js +32 -23
- package/package.json +1 -1
|
@@ -103,14 +103,9 @@ function parseMarko(file) {
|
|
|
103
103
|
);
|
|
104
104
|
if (t.isStringLiteral(result)) {
|
|
105
105
|
// convert to template literal just so that we don't mistake it for a native tag if this is a tag name.
|
|
106
|
-
return
|
|
107
|
-
[
|
|
108
|
-
|
|
109
|
-
raw: result.value,
|
|
110
|
-
cooked: result.value
|
|
111
|
-
})],
|
|
112
|
-
|
|
113
|
-
[]
|
|
106
|
+
return withLoc(
|
|
107
|
+
t.templateLiteral([templateElement(result.value, true)], []),
|
|
108
|
+
value
|
|
114
109
|
);
|
|
115
110
|
} else {
|
|
116
111
|
return result;
|
|
@@ -481,22 +476,30 @@ function parseMarko(file) {
|
|
|
481
476
|
for (const attr of attributes) {
|
|
482
477
|
if (attr.name === "class") {
|
|
483
478
|
foundClassAttr = true;
|
|
484
|
-
if (
|
|
485
|
-
if (t.isArrayExpression(classShorthandValue)) {
|
|
486
|
-
attr.value.elements.push(...classShorthandValue.elements);
|
|
487
|
-
} else {
|
|
488
|
-
attr.value.elements.push(classShorthandValue);
|
|
489
|
-
}
|
|
490
|
-
} else if (
|
|
479
|
+
if (
|
|
491
480
|
t.isStringLiteral(attr.value) &&
|
|
492
481
|
t.isStringLiteral(classShorthandValue))
|
|
493
482
|
{
|
|
494
|
-
attr.value
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
483
|
+
attr.value = t.templateLiteral(
|
|
484
|
+
[
|
|
485
|
+
templateElement("", false),
|
|
486
|
+
templateElement(" ", false),
|
|
487
|
+
templateElement("", true)],
|
|
488
|
+
|
|
489
|
+
[classShorthandValue, attr.value]
|
|
490
|
+
);
|
|
498
491
|
} else {
|
|
499
|
-
attr.value = t.arrayExpression(
|
|
492
|
+
attr.value = t.arrayExpression(
|
|
493
|
+
t.isArrayExpression(classShorthandValue) ?
|
|
494
|
+
classShorthandValue.elements.concat(
|
|
495
|
+
t.isArrayExpression(attr.value) ?
|
|
496
|
+
attr.value.elements :
|
|
497
|
+
attr.value
|
|
498
|
+
) :
|
|
499
|
+
t.isArrayExpression(attr.value) ?
|
|
500
|
+
[classShorthandValue].concat(attr.value.elements) :
|
|
501
|
+
[classShorthandValue, attr.value]
|
|
502
|
+
);
|
|
500
503
|
}
|
|
501
504
|
break;
|
|
502
505
|
}
|
|
@@ -518,9 +521,7 @@ function parseMarko(file) {
|
|
|
518
521
|
);
|
|
519
522
|
}
|
|
520
523
|
}
|
|
521
|
-
|
|
522
|
-
t.markoAttribute("id", currentShorthandId)
|
|
523
|
-
);
|
|
524
|
+
attributes.push(t.markoAttribute("id", currentShorthandId));
|
|
524
525
|
currentShorthandId = undefined;
|
|
525
526
|
}
|
|
526
527
|
|
|
@@ -648,4 +649,12 @@ function parseMarko(file) {
|
|
|
648
649
|
|
|
649
650
|
function sortByStart(a, b) {
|
|
650
651
|
return a.start - b.start;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
function templateElement(value, tail) {
|
|
655
|
+
return t.templateElement({
|
|
656
|
+
tail,
|
|
657
|
+
raw: value,
|
|
658
|
+
cooked: value
|
|
659
|
+
});
|
|
651
660
|
}
|