marko 6.3.54 → 6.3.55

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.
@@ -8957,9 +8957,11 @@ function createStatementTag(keyword) {
8957
8957
  const rawValue = node.rawValue;
8958
8958
  const code = rawValue.replace(keywordReg, "");
8959
8959
  const start = node.start + (rawValue.length - code.length);
8960
- let body = (0, _marko_compiler_babel_utils.parseStatements)(file, code, start, start + code.length);
8961
- if (body.length === 1 && _marko_compiler.types.isBlockStatement(body[0])) body = body[0].body;
8962
- tag.replaceWith(_marko_compiler.types.markoScriptlet(body, true, target));
8960
+ let block = (0, _marko_compiler_babel_utils.parseBlock)(file, code, start, start + code.length);
8961
+ if (block.body.length === 1 && _marko_compiler.types.isBlockStatement(block.body[0])) block = block.body[0];
8962
+ const scriptlet = _marko_compiler.types.markoScriptlet(block.body, true, target);
8963
+ scriptlet.innerComments = block.innerComments;
8964
+ tag.replaceWith(scriptlet);
8963
8965
  },
8964
8966
  parseOptions: {
8965
8967
  statement: true,
@@ -9535,9 +9537,9 @@ var script_default = {
9535
9537
  }
9536
9538
  const start = body[0]?.start;
9537
9539
  const end = body[body.length - 1]?.end;
9538
- const bodyStatements = (0, _marko_compiler_babel_utils.parseStatements)((0, _marko_compiler_babel_utils.getFile)(), code, start, end);
9539
- if (bodyStatements.length) {
9540
- const valueFn = _marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.blockStatement(bodyStatements), !!traverseFindAwait(bodyStatements));
9540
+ const block = (0, _marko_compiler_babel_utils.parseBlock)((0, _marko_compiler_babel_utils.getFile)(), code, start, end);
9541
+ if (block.body.length || block.innerComments) {
9542
+ const valueFn = _marko_compiler.types.arrowFunctionExpression([], block, !!traverseFindAwait(block));
9541
9543
  node.attributes.push(_marko_compiler.types.markoAttribute("value", valueFn));
9542
9544
  }
9543
9545
  node.body.body = [];
@@ -9554,16 +9556,18 @@ var script_default = {
9554
9556
  for (const attr of node.attributes) if (attr.type === "MarkoAttribute" && attr.name === "value") {
9555
9557
  if (seenValueAttr) throw tag.hub.buildError(attr, "Invalid duplicate value attribute.");
9556
9558
  seenValueAttr = true;
9557
- (attr.value.extra ??= {}).isEffect = true;
9558
- addSetupExpr(getOrCreateSection(tag), attr.value);
9559
- (0, _marko_compiler_babel_utils.getProgram)().node.extra.isInteractive = true;
9559
+ if (!isEmptyFunction(attr.value)) {
9560
+ (attr.value.extra ??= {}).isEffect = true;
9561
+ addSetupExpr(getOrCreateSection(tag), attr.value);
9562
+ (0, _marko_compiler_babel_utils.getProgram)().node.extra.isInteractive = true;
9563
+ }
9560
9564
  } else throw tag.hub.buildError(attr, "The [`<script>` tag](https://markojs.com/docs/reference/core-tag#script) does not support html attributes. For a native html [`<script>` tag](https://markojs.com/docs/reference/core-tag#script) use the `html-script` core tag instead.");
9561
9565
  if (!seenValueAttr) dropNodes(getAllTagReferenceNodes(node));
9562
9566
  },
9563
9567
  translate: { exit(tag) {
9564
9568
  const { node } = tag;
9565
9569
  const [valueAttr] = node.attributes;
9566
- if (!valueAttr) {
9570
+ if (!valueAttr?.value.extra?.isEffect) {
9567
9571
  tag.remove();
9568
9572
  return;
9569
9573
  }
@@ -9598,6 +9602,9 @@ var script_default = {
9598
9602
  }],
9599
9603
  types: runtime_info_default.name + "/tags/script.d.marko"
9600
9604
  };
9605
+ function isEmptyFunction(node) {
9606
+ return (_marko_compiler.types.isFunctionExpression(node) || _marko_compiler.types.isArrowFunctionExpression(node)) && _marko_compiler.types.isBlockStatement(node.body) && !node.body.body.length;
9607
+ }
9601
9608
  function isReturnedFunction(node) {
9602
9609
  switch (node.type) {
9603
9610
  case "FunctionDeclaration":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.3.54",
3
+ "version": "6.3.55",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",
@@ -51,14 +51,14 @@
51
51
  }
52
52
  },
53
53
  "dependencies": {
54
- "@marko/compiler": "^5.42.7",
54
+ "@marko/compiler": "^5.42.8",
55
55
  "csstype": "^3.2.3",
56
56
  "fastest-levenshtein": "^1.0.16",
57
57
  "magic-string": "^0.30.21"
58
58
  },
59
59
  "devDependencies": {
60
- "@marko/runtime-tags": "npm:marko@6.3.54",
61
- "marko": "5.39.43"
60
+ "@marko/runtime-tags": "npm:marko@6.3.55",
61
+ "marko": "5.39.44"
62
62
  },
63
63
  "engines": {
64
64
  "node": ">=22"