@marko/compiler 5.37.23 → 5.37.24

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.
@@ -542,34 +542,50 @@ function parseMarko(file) {
542
542
 
543
543
  if (node.body.body.length) {
544
544
  const body = [];
545
+ // When we have a control flow with mixed body and attribute tag content
546
+ // we move any scriptlets, comments or empty nested control flow.
547
+ // This is because they initially ambiguous as to whether
548
+ // they are part of the body or the attributeTags.
549
+ // Otherwise we only move scriptlets.
545
550
  for (const child of node.body.body) {
546
551
  if (
547
552
  t.isMarkoScriptlet(child) ||
548
- isControlFlow && (
549
- t.isMarkoComment(child) ||
550
- child.tagDef?.controlFlow && !child.body.body.length))
553
+ isControlFlow && t.isMarkoComment(child))
551
554
  {
552
- // When we have a control flow with mixed body and attribute tag content
553
- // we move any scriptlets, comments or empty nested control flow.
554
- // This is because they initially ambiguous as to whether
555
- // they are part of the body or the attributeTags.
555
+ attributeTags.push(child);
556
+ } else if (
557
+ isControlFlow &&
558
+ child.tagDef?.controlFlow &&
559
+ !child.body.body.length)
560
+ {
561
+ child.body.attributeTags = true;
556
562
  attributeTags.push(child);
557
563
  } else {
558
564
  body.push(child);
559
565
  }
560
566
  }
561
567
 
562
- if (isControlFlow && body.length) {
563
- onNext();
564
- throw file.buildCodeFrameError(
565
- body[0],
566
- "Cannot have attribute tags and body content under a control flow tag."
567
- );
568
+ if (isControlFlow) {
569
+ if (body.length) {
570
+ onNext();
571
+ throw file.buildCodeFrameError(
572
+ body[0],
573
+ "Cannot have attribute tags and body content under a control flow tag."
574
+ );
575
+ }
576
+
577
+ node.attributeTags = body;
578
+ node.body.body = attributeTags;
579
+ node.body.attributeTags = true;
568
580
  } else {
569
581
  node.body.body = body;
570
582
  }
571
583
 
572
584
  attributeTags.sort(sortByStart);
585
+ } else if (isControlFlow) {
586
+ node.attributeTags = [];
587
+ node.body.body = attributeTags;
588
+ node.body.attributeTags = true;
573
589
  }
574
590
 
575
591
  if (isControlFlow) {
@@ -174,6 +174,10 @@ const MarkoDefinitions = {
174
174
  "MarkoComment"]
175
175
  ),
176
176
  default: []
177
+ },
178
+ attributeTags: {
179
+ validate: (0, _utils.assertValueType)("boolean"),
180
+ default: false
177
181
  }
178
182
  }
179
183
  },
package/dist/types.d.ts CHANGED
@@ -1741,6 +1741,7 @@ export interface MarkoTagBody extends BaseNode {
1741
1741
  type: "MarkoTagBody";
1742
1742
  body: Array<MarkoTag | MarkoCDATA | MarkoText | MarkoPlaceholder | MarkoScriptlet | MarkoComment>;
1743
1743
  params: Array<Identifier | Pattern | RestElement>;
1744
+ attributeTags: boolean;
1744
1745
  typeParameters: TSTypeParameterDeclaration | null;
1745
1746
  }
1746
1747
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/compiler",
3
- "version": "5.37.23",
3
+ "version": "5.37.24",
4
4
  "description": "Marko template to JS compiler.",
5
5
  "keywords": [
6
6
  "babel",
@@ -66,7 +66,7 @@
66
66
  "@babel/traverse": "^7.25.9",
67
67
  "@babel/types": "^7.26.0",
68
68
  "@luxass/strip-json-comments": "^1.3.2",
69
- "@marko/babel-utils": "^6.5.10",
69
+ "@marko/babel-utils": "^6.5.12",
70
70
  "complain": "^1.6.1",
71
71
  "he": "^1.2.0",
72
72
  "htmljs-parser": "^5.5.2",
@@ -80,7 +80,7 @@
80
80
  "source-map-support": "^0.5.21"
81
81
  },
82
82
  "devDependencies": {
83
- "@marko/translator-default": "^6.0.23"
83
+ "@marko/translator-default": "^6.0.24"
84
84
  },
85
85
  "publishConfig": {
86
86
  "access": "public"