marko 6.1.11 → 6.1.13

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.
@@ -113,8 +113,7 @@ let AccessorProp$1 = /* @__PURE__ */ function(AccessorProp) {
113
113
  AccessorProp["CatchContent"] = "#CatchContent";
114
114
  AccessorProp["ClosestBranch"] = "#ClosestBranch";
115
115
  AccessorProp["ClosestBranchId"] = "#ClosestBranchId";
116
- AccessorProp["Creating"] = "#Creating";
117
- AccessorProp["Destroyed"] = "#Destroyed";
116
+ AccessorProp["Gen"] = "#Gen";
118
117
  AccessorProp["DetachedAwait"] = "#DetachedAwait";
119
118
  AccessorProp["EndNode"] = "#EndNode";
120
119
  AccessorProp["Id"] = "#Id";
@@ -123,6 +122,7 @@ let AccessorProp$1 = /* @__PURE__ */ function(AccessorProp) {
123
122
  AccessorProp["ParentBranch"] = "#ParentBranch";
124
123
  AccessorProp["PendingEffects"] = "#PendingEffects";
125
124
  AccessorProp["PendingRenders"] = "#PendingRenders";
125
+ AccessorProp["PendingScopes"] = "#PendingScopes";
126
126
  AccessorProp["PlaceholderBranch"] = "#PlaceholderBranch";
127
127
  AccessorProp["PlaceholderContent"] = "#PlaceholderContent";
128
128
  AccessorProp["Renderer"] = "#Renderer";
@@ -182,15 +182,15 @@ function isNullableExpr(expr) {
182
182
  case "**=": return false;
183
183
  case "||=":
184
184
  case "??=": return isNullableExpr(expr.right) || isNullableExpr(expr.left);
185
- case "&&=": return isNullableExpr(expr.left) && isNullableExpr(expr.right);
185
+ case "&&=": return isNullableExpr(expr.left) || isNullableExpr(expr.right);
186
186
  default: return true;
187
187
  }
188
188
  case "AwaitExpression": return isNullableExpr(expr.argument);
189
- case "ConditionalExpression": return isNullableExpr(expr.consequent) && isNullableExpr(expr.alternate);
189
+ case "ConditionalExpression": return isNullableExpr(expr.consequent) || isNullableExpr(expr.alternate);
190
190
  case "LogicalExpression": switch (expr.operator) {
191
191
  case "||":
192
192
  case "??": return isNullableExpr(expr.right) || isNullableExpr(expr.left);
193
- case "&&": return isNullableExpr(expr.left) && isNullableExpr(expr.right);
193
+ case "&&": return isNullableExpr(expr.left) || isNullableExpr(expr.right);
194
194
  default: return true;
195
195
  }
196
196
  case "ParenthesizedExpression": return isNullableExpr(expr.expression);
@@ -1052,8 +1052,7 @@ let AccessorProp = /* @__PURE__ */ function(AccessorProp) {
1052
1052
  AccessorProp["CatchContent"] = "E";
1053
1053
  AccessorProp["ClosestBranch"] = "F";
1054
1054
  AccessorProp["ClosestBranchId"] = "G";
1055
- AccessorProp["Creating"] = "H";
1056
- AccessorProp["Destroyed"] = "I";
1055
+ AccessorProp["Gen"] = "H";
1057
1056
  AccessorProp["DetachedAwait"] = "V";
1058
1057
  AccessorProp["EndNode"] = "K";
1059
1058
  AccessorProp["Id"] = "L";
@@ -1062,6 +1061,7 @@ let AccessorProp = /* @__PURE__ */ function(AccessorProp) {
1062
1061
  AccessorProp["ParentBranch"] = "N";
1063
1062
  AccessorProp["PendingEffects"] = "J";
1064
1063
  AccessorProp["PendingRenders"] = "W";
1064
+ AccessorProp["PendingScopes"] = "Y";
1065
1065
  AccessorProp["PlaceholderBranch"] = "P";
1066
1066
  AccessorProp["PlaceholderContent"] = "Q";
1067
1067
  AccessorProp["Renderer"] = "R";
@@ -2807,7 +2807,7 @@ function simplifyFunction(fn) {
2807
2807
  case "FunctionDeclaration":
2808
2808
  case "FunctionExpression":
2809
2809
  case "ArrowFunctionExpression": return fn;
2810
- default: return _marko_compiler.types.functionExpression(null, fn.params, fn.body, fn.async, fn.generator);
2810
+ default: return _marko_compiler.types.functionExpression(null, fn.params, fn.body, fn.generator, fn.async);
2811
2811
  }
2812
2812
  }
2813
2813
  //#endregion
@@ -4181,10 +4181,14 @@ var native_tag_default = {
4181
4181
  }
4182
4182
  seen[attr.name] = attr;
4183
4183
  if (injectNonce && attr.name === "nonce") injectNonce = false;
4184
+ if (isEventOrChangeHandler(attr.name)) assertNativeHandlerAttr(tag, attr);
4184
4185
  if (isEventHandler(attr.name)) {
4185
4186
  valueExtra.isEffect = true;
4186
4187
  hasEventHandlers = true;
4187
- } else if (!evaluate(attr.value).confident) hasDynamicAttributes = true;
4188
+ } else {
4189
+ assertValidNativeEventHandlerAttr(tag, attr);
4190
+ if (!evaluate(attr.value).confident) hasDynamicAttributes = true;
4191
+ }
4188
4192
  } else if (_marko_compiler.types.isMarkoSpreadAttribute(attr)) {
4189
4193
  valueExtra.isEffect = true;
4190
4194
  hasEventHandlers = true;
@@ -4593,6 +4597,23 @@ function isInjectNonceTag(tagName) {
4593
4597
  default: return false;
4594
4598
  }
4595
4599
  }
4600
+ function assertNativeHandlerAttr(tag, attr) {
4601
+ if ((0, _marko_compiler_babel_utils.computeNode)(attr.value)?.value) throw tag.hub.buildError(attr.value, `The \`${attr.name}\` ${isEventHandler(attr.name) ? "event handler" : "change handler"} on a [native tag](https://markojs.com/docs/reference/native-tag) must be a function or a falsey value (\`null\`, \`undefined\`, \`false\`, \`0\`, …).`, Error);
4602
+ }
4603
+ const lowercaseEventHandlerReg = /^on[a-z]/;
4604
+ function assertValidNativeEventHandlerAttr(tag, attr) {
4605
+ if (!lowercaseEventHandlerReg.test(attr.name)) return;
4606
+ const { value } = attr;
4607
+ let invalid = _marko_compiler.types.isFunction(value);
4608
+ if (!invalid) {
4609
+ const { confident, computed } = evaluate(value);
4610
+ invalid = confident && !!computed && typeof computed !== "string";
4611
+ }
4612
+ if (invalid) {
4613
+ const suggestion = "on" + attr.name[2].toUpperCase() + attr.name.slice(3);
4614
+ throw tag.hub.buildError(value, `The \`${attr.name}\` attribute on a [native tag](https://markojs.com/docs/reference/native-tag) must be a string or a falsey value (\`null\`, \`undefined\`, \`false\`, \`0\`, …). To attach an event listener, use the \`${suggestion}\` [event handler attribute](https://markojs.com/docs/reference/event-handling) instead.`, Error);
4615
+ }
4616
+ }
4596
4617
  function getCanonicalTagName(tag) {
4597
4618
  const tagName = getTagName(tag);
4598
4619
  switch (tagName) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.1.11",
3
+ "version": "6.1.13",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",