@marko/compiler 5.38.3 → 5.38.4

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.
@@ -142,6 +142,7 @@ Object.assign(_printer.default.prototype, {
142
142
  const isDynamicTag = !t.isStringLiteral(node.name);
143
143
  const tagName = !isDynamicTag && node.name.value;
144
144
  const rawValue = node.rawValue;
145
+ let bodyOverride;
145
146
 
146
147
  if (
147
148
  tagName === "style" &&
@@ -199,28 +200,39 @@ Object.assign(_printer.default.prototype, {
199
200
  this.token("|");
200
201
  }
201
202
 
202
- if (node.attributes.length) {
203
- if (
204
- !(node.attributes && node.attributes[0] && node.attributes[0].default))
205
- {
203
+ let { attributes } = node;
204
+ if (attributes.length) {
205
+ if (tagName === "script") {
206
+ for (let i = attributes.length; i--;) {
207
+ if (attributes[i].value.fromBody) {
208
+ bodyOverride = attributes[i].value.body.body;
209
+ attributes = toSpliced(attributes, i);
210
+ break;
211
+ }
212
+ }
213
+ }
214
+
215
+ if (!(attributes && attributes[0] && attributes[0].default)) {
206
216
  this.token(" ");
207
217
  }
208
218
 
209
- this.printJoin(node.attributes, { separator: spaceSeparator });
219
+ this.printJoin(attributes, { separator: spaceSeparator });
210
220
  }
211
221
  }
212
222
 
213
223
  if (_selfClosingTags.default.voidElements.includes(tagName)) {
214
224
  this.token(">");
215
225
  } else if (
216
- !(node.body.body.length || node.attributeTags.length) ||
226
+ !(bodyOverride || node.body.body.length || node.attributeTags.length) ||
217
227
  _selfClosingTags.default.svgElements.includes(tagName))
218
228
  {
219
229
  this.token("/>");
220
230
  } else {
221
231
  this.token(">");
222
232
  this.newline();
223
- this.printSequence(zipAttributeTagsAndBody(node), { indent: true });
233
+ this.printSequence(bodyOverride || zipAttributeTagsAndBody(node), {
234
+ indent: true
235
+ });
224
236
  this.token("</");
225
237
  if (!isDynamicTag) {
226
238
  this.token(tagName);
@@ -331,4 +343,20 @@ function compareStartLoc(a, b) {
331
343
  a.loc.start.line - b.loc.start.line ||
332
344
  a.loc.start.column - b.loc.start.column);
333
345
 
346
+ }
347
+
348
+ function toSpliced(arr, index) {
349
+ const len = arr.length;
350
+ const result = new Array(len - 1);
351
+ let i = 0;
352
+
353
+ for (; i < index; i++) {
354
+ result[i] = arr[i];
355
+ }
356
+
357
+ for (i++; i < len; i++) {
358
+ result[i - 1] = arr[i];
359
+ }
360
+
361
+ return result;
334
362
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/compiler",
3
- "version": "5.38.3",
3
+ "version": "5.38.4",
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.6.1",
69
+ "@marko/babel-utils": "^6.6.2",
70
70
  "complain": "^1.6.1",
71
71
  "he": "^1.2.0",
72
72
  "htmljs-parser": "^5.5.2",