marko 6.0.73 → 6.0.76

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/debug/dom.js CHANGED
@@ -1004,7 +1004,7 @@ function _if_closure(valueAccessor, ownerConditionalNodeAccessor, branch, fn) {
1004
1004
  const branchAccessor = "ConditionalRenderer:" /* ConditionalRenderer */ + ownerConditionalNodeAccessor;
1005
1005
  const ownerSignal = (scope) => {
1006
1006
  const ifScope = scope[scopeAccessor];
1007
- if (ifScope && !ifScope.___creating && (scope[branchAccessor] ?? branch) === branch) {
1007
+ if (ifScope && !ifScope.___creating && (scope[branchAccessor] || 0) === branch) {
1008
1008
  queueRender(ifScope, childSignal, -1);
1009
1009
  }
1010
1010
  };
@@ -905,7 +905,7 @@ function _if_closure(valueAccessor, ownerConditionalNodeAccessor, branch, fn) {
905
905
  const branchAccessor = "ConditionalRenderer:" /* ConditionalRenderer */ + ownerConditionalNodeAccessor;
906
906
  const ownerSignal = (scope) => {
907
907
  const ifScope = scope[scopeAccessor];
908
- if (ifScope && !ifScope.___creating && (scope[branchAccessor] ?? branch) === branch) {
908
+ if (ifScope && !ifScope.___creating && (scope[branchAccessor] || 0) === branch) {
909
909
  queueRender(ifScope, childSignal, -1);
910
910
  }
911
911
  };
@@ -46,6 +46,7 @@ __export(html_exports, {
46
46
  _escape: () => _escape,
47
47
  _escape_script: () => _escape_script,
48
48
  _escape_style: () => _escape_style,
49
+ _escape_textarea_value: () => _escape_textarea_value,
49
50
  _existing_scope: () => _existing_scope,
50
51
  _for_in: () => _for_in,
51
52
  _for_of: () => _for_of,
@@ -171,7 +172,7 @@ var escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, r
171
172
  function _escape(val) {
172
173
  return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "‍";
173
174
  }
174
- function escapeTextAreaValue(val) {
175
+ function _escape_textarea_value(val) {
175
176
  return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "";
176
177
  }
177
178
  var unsafeScriptReg = /<\/script/g;
@@ -823,7 +824,7 @@ function writeReferenceOr(state, write, val, parent, accessor) {
823
824
  ref.debug = DEBUG.get(val);
824
825
  }
825
826
  if (write(state, val, ref)) return true;
826
- state.refs.delete(ref);
827
+ state.refs.delete(val);
827
828
  return false;
828
829
  }
829
830
  function writeRegistered(state, val, parent, accessor, { access, scope, getter }) {
@@ -2014,7 +2015,11 @@ function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, serializeS
2014
2015
  const shouldWriteBranch = resumeBranch && branchIndex !== void 0;
2015
2016
  if (shouldWriteBranch) {
2016
2017
  writeScope(scopeId, {
2017
- ["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: resumeMarker ? branchIndex : void 0,
2018
+ // TODO: technically conditional renderer should only be written when either the
2019
+ // condition is stateful, or if there are direct closures.
2020
+ // It may make sense to pass in another arg for this.
2021
+ ["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: branchIndex || void 0,
2022
+ // we convert 0 to undefined since the runtime defaults branch to 0.
2018
2023
  ["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
2019
2024
  });
2020
2025
  }
@@ -2708,7 +2713,7 @@ function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange) {
2708
2713
  valueChange
2709
2714
  );
2710
2715
  }
2711
- return escapeTextAreaValue(value);
2716
+ return _escape_textarea_value(value);
2712
2717
  }
2713
2718
  function _attr_input_value(scopeId, nodeAccessor, value, valueChange) {
2714
2719
  if (valueChange) {
@@ -3457,6 +3462,7 @@ function NOOP3() {
3457
3462
  _escape,
3458
3463
  _escape_script,
3459
3464
  _escape_style,
3465
+ _escape_textarea_value,
3460
3466
  _existing_scope,
3461
3467
  _for_in,
3462
3468
  _for_of,
@@ -85,7 +85,7 @@ var escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, r
85
85
  function _escape(val) {
86
86
  return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "&zwj;";
87
87
  }
88
- function escapeTextAreaValue(val) {
88
+ function _escape_textarea_value(val) {
89
89
  return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "";
90
90
  }
91
91
  var unsafeScriptReg = /<\/script/g;
@@ -737,7 +737,7 @@ function writeReferenceOr(state, write, val, parent, accessor) {
737
737
  ref.debug = DEBUG.get(val);
738
738
  }
739
739
  if (write(state, val, ref)) return true;
740
- state.refs.delete(ref);
740
+ state.refs.delete(val);
741
741
  return false;
742
742
  }
743
743
  function writeRegistered(state, val, parent, accessor, { access, scope, getter }) {
@@ -1928,7 +1928,11 @@ function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, serializeS
1928
1928
  const shouldWriteBranch = resumeBranch && branchIndex !== void 0;
1929
1929
  if (shouldWriteBranch) {
1930
1930
  writeScope(scopeId, {
1931
- ["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: resumeMarker ? branchIndex : void 0,
1931
+ // TODO: technically conditional renderer should only be written when either the
1932
+ // condition is stateful, or if there are direct closures.
1933
+ // It may make sense to pass in another arg for this.
1934
+ ["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: branchIndex || void 0,
1935
+ // we convert 0 to undefined since the runtime defaults branch to 0.
1932
1936
  ["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
1933
1937
  });
1934
1938
  }
@@ -2622,7 +2626,7 @@ function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange) {
2622
2626
  valueChange
2623
2627
  );
2624
2628
  }
2625
- return escapeTextAreaValue(value);
2629
+ return _escape_textarea_value(value);
2626
2630
  }
2627
2631
  function _attr_input_value(scopeId, nodeAccessor, value, valueChange) {
2628
2632
  if (valueChange) {
@@ -3370,6 +3374,7 @@ export {
3370
3374
  _escape,
3371
3375
  _escape_script,
3372
3376
  _escape_style,
3377
+ _escape_textarea_value,
3373
3378
  _existing_scope,
3374
3379
  _for_in,
3375
3380
  _for_of,
package/dist/dom.js CHANGED
@@ -643,7 +643,7 @@ function _for_closure(valueAccessor, ownerLoopNodeAccessor, fn) {
643
643
  function _if_closure(valueAccessor, ownerConditionalNodeAccessor, branch, fn) {
644
644
  let childSignal = closure(valueAccessor, fn), scopeAccessor = "d" /* ConditionalScope */ + ownerConditionalNodeAccessor, branchAccessor = "c" /* ConditionalRenderer */ + ownerConditionalNodeAccessor, ownerSignal = (scope) => {
645
645
  let ifScope = scope[scopeAccessor];
646
- ifScope && !ifScope.q && (scope[branchAccessor] ?? branch) === branch && queueRender(ifScope, childSignal, -1);
646
+ ifScope && !ifScope.q && (scope[branchAccessor] || 0) === branch && queueRender(ifScope, childSignal, -1);
647
647
  };
648
648
  return ownerSignal._ = childSignal, ownerSignal;
649
649
  }
package/dist/dom.mjs CHANGED
@@ -547,7 +547,7 @@ function _for_closure(valueAccessor, ownerLoopNodeAccessor, fn) {
547
547
  function _if_closure(valueAccessor, ownerConditionalNodeAccessor, branch, fn) {
548
548
  let childSignal = closure(valueAccessor, fn), scopeAccessor = "d" /* ConditionalScope */ + ownerConditionalNodeAccessor, branchAccessor = "c" /* ConditionalRenderer */ + ownerConditionalNodeAccessor, ownerSignal = (scope) => {
549
549
  let ifScope = scope[scopeAccessor];
550
- ifScope && !ifScope.q && (scope[branchAccessor] ?? branch) === branch && queueRender(ifScope, childSignal, -1);
550
+ ifScope && !ifScope.q && (scope[branchAccessor] || 0) === branch && queueRender(ifScope, childSignal, -1);
551
551
  };
552
552
  return ownerSignal._ = childSignal, ownerSignal;
553
553
  }
@@ -1,5 +1,5 @@
1
1
  export declare function _unescaped(val: unknown): string;
2
2
  export declare function _escape(val: unknown): string;
3
- export declare function escapeTextAreaValue(val: unknown): string;
3
+ export declare function _escape_textarea_value(val: unknown): string;
4
4
  export declare function _escape_script(val: unknown): string;
5
5
  export declare function _escape_style(val: unknown): string;
package/dist/html.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { attrTag, attrTags } from "./common/attr-tag";
2
2
  export { _attr, _attr_class, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_input_checked, _attr_input_checkedValue, _attr_input_value, _attr_option_value, _attr_select_value, _attr_style, _attr_textarea_value, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, } from "./html/attrs";
3
3
  export { compat } from "./html/compat";
4
- export { _escape, _escape_script, _escape_style, _unescaped, } from "./html/content";
4
+ export { _escape, _escape_script, _escape_style, _escape_textarea_value, _unescaped, } from "./html/content";
5
5
  export { _content, _content_resume, _dynamic_tag } from "./html/dynamic-tag";
6
6
  export { forIn, forInBy, forOf, forOfBy, forStepBy, forTo, forUntil, } from "./html/for";
7
7
  export { _template } from "./html/template";
package/dist/html.js CHANGED
@@ -43,6 +43,7 @@ __export(html_exports, {
43
43
  _escape: () => _escape,
44
44
  _escape_script: () => _escape_script,
45
45
  _escape_style: () => _escape_style,
46
+ _escape_textarea_value: () => _escape_textarea_value,
46
47
  _existing_scope: () => _existing_scope,
47
48
  _for_in: () => _for_in,
48
49
  _for_of: () => _for_of,
@@ -140,7 +141,7 @@ var unsafeXMLReg = /[<&]/g, replaceUnsafeXML = (c) => c === "&" ? "&amp;" : "&lt
140
141
  function _escape(val) {
141
142
  return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "&zwj;";
142
143
  }
143
- function escapeTextAreaValue(val) {
144
+ function _escape_textarea_value(val) {
144
145
  return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "";
145
146
  }
146
147
  var unsafeScriptReg = /<\/script/g, escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C/script") : str;
@@ -580,7 +581,7 @@ function writeReferenceOr(state, write, val, parent, accessor) {
580
581
  return registered ? writeRegistered(state, val, parent, accessor, registered) : (state.refs.set(
581
582
  val,
582
583
  ref = new Reference(parent, accessor, state.flush, state.buf.length)
583
- ), write(state, val, ref) ? !0 : (state.refs.delete(ref), !1));
584
+ ), write(state, val, ref) ? !0 : (state.refs.delete(val), !1));
584
585
  }
585
586
  function writeRegistered(state, val, parent, accessor, { access, scope, getter }) {
586
587
  if (scope) {
@@ -1306,7 +1307,11 @@ function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, serializeS
1306
1307
  resumeMarker && resumeBranch && !singleNode && $chunk.writeHTML(state.mark("[" /* BranchStart */, ""));
1307
1308
  let branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb(), shouldWriteBranch = resumeBranch && branchIndex !== void 0;
1308
1309
  shouldWriteBranch && writeScope(scopeId, {
1309
- ["c" /* ConditionalRenderer */ + accessor]: resumeMarker ? branchIndex : void 0,
1310
+ // TODO: technically conditional renderer should only be written when either the
1311
+ // condition is stateful, or if there are direct closures.
1312
+ // It may make sense to pass in another arg for this.
1313
+ ["c" /* ConditionalRenderer */ + accessor]: branchIndex || void 0,
1314
+ // we convert 0 to undefined since the runtime defaults branch to 0.
1310
1315
  ["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
1311
1316
  }), writeBranchEnd(
1312
1317
  scopeId,
@@ -1721,7 +1726,7 @@ function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange) {
1721
1726
  nodeAccessor,
1722
1727
  void 0,
1723
1728
  valueChange
1724
- ), escapeTextAreaValue(value);
1729
+ ), _escape_textarea_value(value);
1725
1730
  }
1726
1731
  function _attr_input_value(scopeId, nodeAccessor, value, valueChange) {
1727
1732
  return valueChange && writeControlledScope(
@@ -2250,6 +2255,7 @@ function NOOP3() {
2250
2255
  _escape,
2251
2256
  _escape_script,
2252
2257
  _escape_style,
2258
+ _escape_textarea_value,
2253
2259
  _existing_scope,
2254
2260
  _for_in,
2255
2261
  _for_of,
package/dist/html.mjs CHANGED
@@ -57,7 +57,7 @@ var unsafeXMLReg = /[<&]/g, replaceUnsafeXML = (c) => c === "&" ? "&amp;" : "&lt
57
57
  function _escape(val) {
58
58
  return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "&zwj;";
59
59
  }
60
- function escapeTextAreaValue(val) {
60
+ function _escape_textarea_value(val) {
61
61
  return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "";
62
62
  }
63
63
  var unsafeScriptReg = /<\/script/g, escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C/script") : str;
@@ -497,7 +497,7 @@ function writeReferenceOr(state, write, val, parent, accessor) {
497
497
  return registered ? writeRegistered(state, val, parent, accessor, registered) : (state.refs.set(
498
498
  val,
499
499
  ref = new Reference(parent, accessor, state.flush, state.buf.length)
500
- ), write(state, val, ref) ? !0 : (state.refs.delete(ref), !1));
500
+ ), write(state, val, ref) ? !0 : (state.refs.delete(val), !1));
501
501
  }
502
502
  function writeRegistered(state, val, parent, accessor, { access, scope, getter }) {
503
503
  if (scope) {
@@ -1223,7 +1223,11 @@ function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, serializeS
1223
1223
  resumeMarker && resumeBranch && !singleNode && $chunk.writeHTML(state.mark("[" /* BranchStart */, ""));
1224
1224
  let branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb(), shouldWriteBranch = resumeBranch && branchIndex !== void 0;
1225
1225
  shouldWriteBranch && writeScope(scopeId, {
1226
- ["c" /* ConditionalRenderer */ + accessor]: resumeMarker ? branchIndex : void 0,
1226
+ // TODO: technically conditional renderer should only be written when either the
1227
+ // condition is stateful, or if there are direct closures.
1228
+ // It may make sense to pass in another arg for this.
1229
+ ["c" /* ConditionalRenderer */ + accessor]: branchIndex || void 0,
1230
+ // we convert 0 to undefined since the runtime defaults branch to 0.
1227
1231
  ["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
1228
1232
  }), writeBranchEnd(
1229
1233
  scopeId,
@@ -1638,7 +1642,7 @@ function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange) {
1638
1642
  nodeAccessor,
1639
1643
  void 0,
1640
1644
  valueChange
1641
- ), escapeTextAreaValue(value);
1645
+ ), _escape_textarea_value(value);
1642
1646
  }
1643
1647
  function _attr_input_value(scopeId, nodeAccessor, value, valueChange) {
1644
1648
  return valueChange && writeControlledScope(
@@ -2166,6 +2170,7 @@ export {
2166
2170
  _escape,
2167
2171
  _escape_script,
2168
2172
  _escape_style,
2173
+ _escape_textarea_value,
2169
2174
  _existing_scope,
2170
2175
  _for_in,
2171
2176
  _for_of,
@@ -4775,7 +4775,7 @@ function trackParamsReferences(body, type, upstreamAlias) {
4775
4775
  section,
4776
4776
  paramsBinding,
4777
4777
  void 0,
4778
- addNumericPropertiesUntil(void 0, i - 1)
4778
+ i > 0 ? addNumericPropertiesUntil(void 0, i - 1) : void 0
4779
4779
  );
4780
4780
  } else if (import_compiler25.types.isLVal(param)) {
4781
4781
  createBindingsAndTrackReferences(
@@ -4978,10 +4978,7 @@ function createBindingsAndTrackReferences(lVal, type, scope, section, upstreamAl
4978
4978
  i++;
4979
4979
  if (element) {
4980
4980
  if (element.type === "RestElement") {
4981
- excludeProperties = addNumericPropertiesUntil(
4982
- excludeProperties,
4983
- i - 1
4984
- );
4981
+ excludeProperties = i > 0 ? addNumericPropertiesUntil(excludeProperties, i - 1) : void 0;
4985
4982
  createBindingsAndTrackReferences(
4986
4983
  element.argument,
4987
4984
  type,
@@ -6392,7 +6389,7 @@ var native_tag_default = {
6392
6389
  }
6393
6390
  }
6394
6391
  assertExclusiveControllableGroups(tag, seen);
6395
- if (node.var || hasEventHandlers || hasDynamicAttributes) {
6392
+ if (node.var || hasEventHandlers || hasDynamicAttributes || getRelatedControllable(tagName, seen)?.special) {
6396
6393
  const tagExtra = node.extra ??= {};
6397
6394
  const tagSection = getOrCreateSection(tag);
6398
6395
  const nodeBinding = tagExtra[kNativeTagBinding] = createBinding(
@@ -6400,7 +6397,9 @@ var native_tag_default = {
6400
6397
  0 /* dom */,
6401
6398
  tagSection
6402
6399
  );
6403
- (0, import_babel_utils25.getProgram)().node.extra.isInteractive ||= hasEventHandlers;
6400
+ if (hasEventHandlers) {
6401
+ (0, import_babel_utils25.getProgram)().node.extra.isInteractive = true;
6402
+ }
6404
6403
  if (spreadReferenceNodes) {
6405
6404
  if (relatedControllable && !relatedControllable.attrs.every(Boolean)) {
6406
6405
  for (const attr of relatedControllable.attrs) {
@@ -6486,12 +6485,17 @@ var native_tag_default = {
6486
6485
  const { staticAttrs, staticControllable, skipExpression } = usedAttrs;
6487
6486
  let { spreadExpression } = usedAttrs;
6488
6487
  if (staticControllable) {
6489
- const { helper, attrs } = staticControllable;
6490
6488
  if (tagName !== "select" && tagName !== "textarea") {
6491
- const values = attrs.map((attr) => attr?.value);
6492
- write`${callRuntime(helper, getScopeIdIdentifier(tagSection), visitAccessor, ...values)}`;
6489
+ write`${callRuntime(
6490
+ staticControllable.helper,
6491
+ getScopeIdIdentifier(tagSection),
6492
+ visitAccessor,
6493
+ ...staticControllable.attrs.map((attr) => attr?.value)
6494
+ )}`;
6495
+ }
6496
+ if (!(staticControllable.special && !staticControllable.attrs[1])) {
6497
+ addHTMLEffectCall(tagSection, void 0);
6493
6498
  }
6494
- addHTMLEffectCall(tagSection, void 0);
6495
6499
  }
6496
6500
  let writeAtStartOfBody;
6497
6501
  if (tagName === "select") {
@@ -6539,14 +6543,16 @@ var native_tag_default = {
6539
6543
  );
6540
6544
  spreadExpression = spreadIdentifier;
6541
6545
  }
6542
- if (value || valueChange) {
6546
+ if (valueChange) {
6543
6547
  writeAtStartOfBody = callRuntime(
6544
6548
  "_attr_textarea_value",
6545
6549
  getScopeIdIdentifier(getSection(tag)),
6546
- getScopeAccessorLiteral(nodeBinding),
6550
+ visitAccessor,
6547
6551
  value,
6548
6552
  valueChange
6549
6553
  );
6554
+ } else if (value) {
6555
+ writeAtStartOfBody = callRuntime("_escape_textarea_value", value);
6550
6556
  }
6551
6557
  }
6552
6558
  for (const attr of staticAttrs) {
@@ -6683,7 +6689,7 @@ var native_tag_default = {
6683
6689
  callRuntime(
6684
6690
  "_attr_select_value",
6685
6691
  getScopeIdIdentifier(getSection(tag)),
6686
- getScopeAccessorLiteral(nodeBinding),
6692
+ nodeBinding && getScopeAccessorLiteral(nodeBinding),
6687
6693
  selectArgs.value,
6688
6694
  selectArgs.valueChange,
6689
6695
  import_compiler32.types.arrowFunctionExpression(
@@ -6798,14 +6804,16 @@ var native_tag_default = {
6798
6804
  callRuntime(helper, scopeIdentifier, visitAccessor, ...values)
6799
6805
  )
6800
6806
  );
6801
- addStatement(
6802
- "effect",
6803
- tagSection,
6804
- void 0,
6805
- import_compiler32.types.expressionStatement(
6806
- callRuntime(`${helper}_script`, scopeIdentifier, visitAccessor)
6807
- )
6808
- );
6807
+ if (!(staticControllable.special && !attrs[1])) {
6808
+ addStatement(
6809
+ "effect",
6810
+ tagSection,
6811
+ void 0,
6812
+ import_compiler32.types.expressionStatement(
6813
+ callRuntime(`${helper}_script`, scopeIdentifier, visitAccessor)
6814
+ )
6815
+ );
6816
+ }
6809
6817
  }
6810
6818
  for (const attr of staticAttrs) {
6811
6819
  const { name: name2, value } = attr;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.0.73",
3
+ "version": "6.0.76",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",