marko 5.29.2 → 5.30.0

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.
Files changed (167) hide show
  1. package/README.md +1 -1
  2. package/bin/markoc.js +18 -18
  3. package/dist/core-tags/core/await/renderer.js +5 -1
  4. package/dist/node_modules/@internal/components-beginComponent/index.js +13 -3
  5. package/dist/node_modules/@internal/components-define-widget-legacy/index-browser.js +331 -0
  6. package/dist/node_modules/@internal/components-define-widget-legacy/index.js +18 -0
  7. package/dist/node_modules/@internal/components-define-widget-legacy/package.json +11 -0
  8. package/dist/node_modules/@internal/components-entry/index-browser.js +2 -2
  9. package/dist/node_modules/@internal/components-entry/index.js +73 -45
  10. package/dist/node_modules/@internal/components-entry-legacy/index-browser.js +74 -0
  11. package/dist/node_modules/@internal/components-entry-legacy/index.js +15 -0
  12. package/dist/node_modules/@internal/components-entry-legacy/package.json +11 -0
  13. package/dist/node_modules/@internal/components-registry/index-browser.js +70 -43
  14. package/dist/node_modules/@internal/components-registry/index.js +2 -2
  15. package/dist/node_modules/@internal/components-util/index-browser.js +17 -17
  16. package/dist/node_modules/@internal/components-util/index.js +18 -8
  17. package/dist/node_modules/@internal/create-readable/index-browser.js +1 -1
  18. package/dist/node_modules/@internal/create-readable/index.js +9 -9
  19. package/dist/node_modules/@internal/set-immediate/index-browser.js +1 -1
  20. package/dist/node_modules/@internal/set-immediate/index-worker.js +2 -2
  21. package/dist/node_modules/@internal/set-immediate/index.js +2 -2
  22. package/dist/runtime/RenderResult.js +3 -3
  23. package/dist/runtime/components/Component.js +146 -148
  24. package/dist/runtime/components/ComponentDef.js +41 -27
  25. package/dist/runtime/components/ComponentsContext.js +6 -6
  26. package/dist/runtime/components/GlobalComponentsContext.js +3 -3
  27. package/dist/runtime/components/KeySequence.js +3 -3
  28. package/dist/runtime/components/ServerComponent.js +13 -13
  29. package/dist/runtime/components/State.js +27 -27
  30. package/dist/runtime/components/attach-detach.js +7 -7
  31. package/dist/runtime/components/defineComponent.js +5 -5
  32. package/dist/runtime/components/dom-data.js +6 -6
  33. package/dist/runtime/components/event-delegation.js +10 -10
  34. package/dist/runtime/components/legacy/browser.json +9 -0
  35. package/dist/runtime/components/legacy/defineComponent-legacy.js +32 -0
  36. package/dist/runtime/components/legacy/defineRenderer-legacy.js +171 -0
  37. package/dist/runtime/components/legacy/defineWidget-legacy.js +1 -0
  38. package/dist/runtime/components/legacy/dependencies/html.js +3 -0
  39. package/dist/runtime/components/legacy/dependencies/index.js +178 -0
  40. package/dist/runtime/components/legacy/dependencies/vdom.js +3 -0
  41. package/dist/runtime/components/legacy/index.js +1 -0
  42. package/dist/runtime/components/legacy/jquery.js +51 -0
  43. package/dist/runtime/components/legacy/ready.js +152 -0
  44. package/dist/runtime/components/legacy/renderer-legacy.js +230 -0
  45. package/dist/runtime/components/renderer.js +30 -26
  46. package/dist/runtime/components/update-manager.js +10 -10
  47. package/dist/runtime/createOut.js +1 -1
  48. package/dist/runtime/dom-insert.js +5 -5
  49. package/dist/runtime/helpers/_change-case.js +2 -2
  50. package/dist/runtime/helpers/dynamic-tag.js +7 -9
  51. package/dist/runtime/helpers/style-value.js +7 -2
  52. package/dist/runtime/html/AsyncStream.js +20 -20
  53. package/dist/runtime/html/BufferedWriter.js +2 -2
  54. package/dist/runtime/html/helpers/_dynamic-attr.js +2 -2
  55. package/dist/runtime/html/helpers/attr.js +19 -6
  56. package/dist/runtime/html/helpers/attrs.js +7 -0
  57. package/dist/runtime/html/helpers/data-marko.js +2 -2
  58. package/dist/runtime/html/helpers/escape-quotes.js +1 -1
  59. package/dist/runtime/html/helpers/escape-xml.js +1 -1
  60. package/dist/runtime/html/helpers/merge-attrs.js +38 -7
  61. package/dist/runtime/html/index.js +2 -2
  62. package/dist/runtime/renderable.js +9 -6
  63. package/dist/runtime/vdom/AsyncVDOMBuilder.js +86 -86
  64. package/dist/runtime/vdom/VComponent.js +3 -3
  65. package/dist/runtime/vdom/VDocumentFragment.js +7 -7
  66. package/dist/runtime/vdom/VElement.js +61 -50
  67. package/dist/runtime/vdom/VFragment.js +8 -8
  68. package/dist/runtime/vdom/VNode.js +36 -36
  69. package/dist/runtime/vdom/VText.js +8 -8
  70. package/dist/runtime/vdom/helpers/attrs.js +24 -4
  71. package/dist/runtime/vdom/helpers/merge-attrs.js +16 -0
  72. package/dist/runtime/vdom/helpers/v-element.js +1 -1
  73. package/dist/runtime/vdom/helpers/v-text.js +1 -1
  74. package/dist/runtime/vdom/hot-reload.js +19 -19
  75. package/dist/runtime/vdom/index.js +2 -2
  76. package/dist/runtime/vdom/morphdom/fragment.js +5 -5
  77. package/dist/runtime/vdom/morphdom/helpers.js +5 -5
  78. package/dist/runtime/vdom/morphdom/index.js +56 -56
  79. package/dist/runtime/vdom/morphdom/specialElHandlers.js +7 -7
  80. package/dist/runtime/vdom/preserve-attrs.js +1 -1
  81. package/dist/runtime/vdom/vdom.js +14 -14
  82. package/docs/10-awesome-marko-features.md +1 -1
  83. package/docs/body-content.md +3 -3
  84. package/docs/class-components.md +6 -6
  85. package/docs/cloudflare-workers.md +3 -3
  86. package/docs/compiler.md +5 -5
  87. package/docs/express.md +2 -2
  88. package/docs/http.md +1 -1
  89. package/docs/koa.md +1 -1
  90. package/docs/lasso.md +1 -1
  91. package/docs/marko-vs-react.md +2 -2
  92. package/docs/rendering.md +6 -6
  93. package/docs/rollup.md +30 -30
  94. package/docs/troubleshooting-streaming.md +1 -1
  95. package/docs/typescript.md +1 -1
  96. package/docs/vite.md +3 -3
  97. package/docs/webpack.md +25 -25
  98. package/docs/why-is-marko-fast.md +2 -2
  99. package/index.d.ts +1 -0
  100. package/legacy-components-browser.marko +15 -0
  101. package/legacy-components.js +7 -0
  102. package/package.json +51 -45
  103. package/src/compiler/config.js +1 -1
  104. package/src/compiler/index.js +5 -5
  105. package/src/core-tags/core/__flush_here_and_after__.js +1 -1
  106. package/src/core-tags/core/await/AsyncValue.js +1 -1
  107. package/src/core-tags/core/await/renderer.js +8 -4
  108. package/src/core-tags/core/await/reorderer-renderer.js +1 -1
  109. package/src/node-require/browser-refresh.js +2 -2
  110. package/src/node-require/index.js +2 -2
  111. package/src/node_modules/@internal/components-beginComponent/index.js +16 -6
  112. package/src/node_modules/@internal/components-define-widget-legacy/index-browser.js +331 -0
  113. package/src/node_modules/@internal/components-define-widget-legacy/index.js +18 -0
  114. package/src/node_modules/@internal/components-define-widget-legacy/package.json +11 -0
  115. package/src/node_modules/@internal/components-entry/index.js +65 -37
  116. package/src/node_modules/@internal/components-entry-legacy/index-browser.js +74 -0
  117. package/src/node_modules/@internal/components-entry-legacy/index.js +15 -0
  118. package/src/node_modules/@internal/components-entry-legacy/package.json +11 -0
  119. package/src/node_modules/@internal/components-registry/index-browser.js +33 -6
  120. package/src/node_modules/@internal/components-util/index.js +10 -0
  121. package/src/runtime/RenderResult.js +3 -3
  122. package/src/runtime/components/Component.js +16 -18
  123. package/src/runtime/components/ComponentDef.js +22 -8
  124. package/src/runtime/components/ComponentsContext.js +1 -1
  125. package/src/runtime/components/State.js +2 -2
  126. package/src/runtime/components/attach-detach.js +1 -1
  127. package/src/runtime/components/dom-data.js +1 -1
  128. package/src/runtime/components/legacy/browser.json +9 -0
  129. package/src/runtime/components/legacy/defineComponent-legacy.js +32 -0
  130. package/src/runtime/components/legacy/defineRenderer-legacy.js +171 -0
  131. package/src/runtime/components/legacy/defineWidget-legacy.js +1 -0
  132. package/src/runtime/components/legacy/dependencies/html.js +3 -0
  133. package/src/runtime/components/legacy/dependencies/index.js +178 -0
  134. package/src/runtime/components/legacy/dependencies/vdom.js +3 -0
  135. package/src/runtime/components/legacy/index.js +1 -0
  136. package/src/runtime/components/legacy/jquery.js +51 -0
  137. package/src/runtime/components/legacy/ready.js +152 -0
  138. package/src/runtime/components/legacy/renderer-legacy.js +230 -0
  139. package/src/runtime/components/renderer.js +4 -0
  140. package/src/runtime/components/update-manager.js +1 -1
  141. package/src/runtime/dom-insert.js +1 -1
  142. package/src/runtime/helpers/dynamic-tag.js +2 -4
  143. package/src/runtime/helpers/style-value.js +7 -2
  144. package/src/runtime/html/AsyncStream.js +5 -5
  145. package/src/runtime/html/BufferedWriter.js +1 -1
  146. package/src/runtime/html/StringWriter.js +1 -1
  147. package/src/runtime/html/helpers/attr.js +15 -2
  148. package/src/runtime/html/helpers/attrs.js +7 -0
  149. package/src/runtime/html/helpers/merge-attrs.js +38 -7
  150. package/src/runtime/html/hot-reload.js +1 -1
  151. package/src/runtime/html/index.js +2 -2
  152. package/src/runtime/renderable.js +5 -2
  153. package/src/runtime/vdom/AsyncVDOMBuilder.js +2 -2
  154. package/src/runtime/vdom/VComponent.js +1 -1
  155. package/src/runtime/vdom/VDocumentFragment.js +1 -1
  156. package/src/runtime/vdom/VElement.js +17 -6
  157. package/src/runtime/vdom/VFragment.js +1 -1
  158. package/src/runtime/vdom/VNode.js +1 -1
  159. package/src/runtime/vdom/VText.js +1 -1
  160. package/src/runtime/vdom/helpers/attrs.js +26 -6
  161. package/src/runtime/vdom/helpers/merge-attrs.js +16 -0
  162. package/src/runtime/vdom/hot-reload.js +1 -1
  163. package/src/runtime/vdom/index.js +2 -2
  164. package/src/runtime/vdom/morphdom/fragment.js +1 -1
  165. package/src/runtime/vdom/morphdom/specialElHandlers.js +1 -1
  166. package/src/taglib/index.js +1 -1
  167. package/tags-html.d.ts +9 -0
@@ -23,7 +23,7 @@ var voidWriter = {
23
23
  },
24
24
  toString: function () {
25
25
  return "";
26
- }
26
+ },
27
27
  };
28
28
 
29
29
  function State(root, stream, writer, events) {
@@ -235,7 +235,7 @@ var proto = (AsyncStream.prototype = {
235
235
 
236
236
  state.events.emit("beginAsync", {
237
237
  out: newStream,
238
- parentOut: this
238
+ parentOut: this,
239
239
  });
240
240
 
241
241
  return newStream;
@@ -498,7 +498,7 @@ var proto = (AsyncStream.prototype = {
498
498
  newOut.on("error", this.emit.bind(this, "error"));
499
499
  this._state.events.emit("beginDetachedAsync", {
500
500
  out: newOut,
501
- parentOut: this
501
+ parentOut: this,
502
502
  });
503
503
  return newOut;
504
504
  },
@@ -655,7 +655,7 @@ var proto = (AsyncStream.prototype = {
655
655
  this.___assignedComponentDef = componentDef;
656
656
  this.___assignedKey = key;
657
657
  this.___assignedCustomEvents = customEvents;
658
- }
658
+ },
659
659
  });
660
660
 
661
661
  // alias:
@@ -669,6 +669,6 @@ function getNonMarkoStack(error) {
669
669
  .toString()
670
670
  .split("\n")
671
671
  .slice(1)
672
- .filter(line => !/\/node_modules\/marko\//.test(line))
672
+ .filter((line) => !/\/node_modules\/marko\//.test(line))
673
673
  .join("\n");
674
674
  }
@@ -30,7 +30,7 @@ BufferedWriter.prototype = Object.assign(
30
30
  if (!this._wrapped.isTTY) {
31
31
  this._wrapped.end();
32
32
  }
33
- }
33
+ },
34
34
  },
35
35
  StringWriter.prototype
36
36
  );
@@ -67,7 +67,7 @@ StringWriter.prototype = {
67
67
  str += `<script${nonceAttr}>${this._scripts}</script>`;
68
68
  }
69
69
  return str;
70
- }
70
+ },
71
71
  };
72
72
 
73
73
  module.exports = StringWriter;
@@ -3,6 +3,7 @@
3
3
  var escapeQuoteHelpers = require("./escape-quotes");
4
4
  var escapeDoubleQuotes = escapeQuoteHelpers.___escapeDoubleQuotes;
5
5
  var escapeSingleQuotes = escapeQuoteHelpers.___escapeSingleQuotes;
6
+ var complain = "MARKO_DEBUG" && require("complain");
6
7
 
7
8
  module.exports = maybeEmptyAttr;
8
9
 
@@ -26,8 +27,20 @@ function notEmptyAttr(name, value) {
26
27
  case "number":
27
28
  return " " + name + "=" + value;
28
29
  case "object":
29
- if (value instanceof RegExp) {
30
- return " " + name + doubleQuote(value.source);
30
+ switch (value.toString) {
31
+ case Object.prototype.toString:
32
+ case Array.prototype.toString:
33
+ // eslint-disable-next-line no-constant-condition
34
+ if ("MARKO_DEBUG") {
35
+ complain(
36
+ "Relying on JSON.stringify for attribute values is deprecated, in future versions of Marko these will be cast to strings instead.",
37
+ { locationIndex: 2 }
38
+ );
39
+ }
40
+
41
+ return " " + name + singleQuote(JSON.stringify(value), 2);
42
+ case RegExp.prototype.toString:
43
+ return " " + name + guessQuotes(value.source);
31
44
  }
32
45
  }
33
46
 
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ var complain = "MARKO_DEBUG" && require("complain");
3
4
  var dynamicAttrHelper = require("./_dynamic-attr");
4
5
 
5
6
  module.exports = function attrs(arg) {
@@ -11,6 +12,12 @@ module.exports = function attrs(arg) {
11
12
  }
12
13
  return result;
13
14
  case "string":
15
+ // eslint-disable-next-line no-constant-condition
16
+ if ("MARKO_DEBUG") {
17
+ complain(
18
+ "Passing a string as a dynamic attribute value is deprecated - More details: https://github.com/marko-js/marko/wiki/Deprecation:-String-as-dynamic-attribute-value"
19
+ );
20
+ }
14
21
  return arg;
15
22
  default:
16
23
  return "";
@@ -1,20 +1,51 @@
1
1
  "use strict";
2
2
 
3
+ var complain = "MARKO_DEBUG" && require("complain");
3
4
  var dynamicAttrHelper = require("./_dynamic-attr");
4
5
 
5
6
  /**
6
7
  * Merges attribute objects into a string.
7
8
  */
8
9
  module.exports = function mergeAttrs() {
9
- var result = "";
10
+ var i = arguments.length;
11
+ var last = arguments[--i];
10
12
  var seen = new Set();
13
+ var result = "";
14
+ var attrName;
15
+
16
+ if (typeof last === "string") {
17
+ // eslint-disable-next-line no-constant-condition
18
+ if ("MARKO_DEBUG") {
19
+ complain(
20
+ "Passing a string as dynamic attributes ('<div ${string}>' or '<div ...string>') is deprecated, use an object instead."
21
+ );
22
+ }
23
+
24
+ result += last[0] === " " ? last : " " + last;
25
+ } else {
26
+ for (attrName in last) {
27
+ result += dynamicAttrHelper(attrName, last[attrName]);
28
+ seen.add(attrName);
29
+ }
30
+ }
31
+
32
+ while (i) {
33
+ var arg = arguments[--i];
34
+ if (typeof arg === "string") {
35
+ // eslint-disable-next-line no-constant-condition
36
+ if ("MARKO_DEBUG") {
37
+ complain(
38
+ "Passing a string as dynamic attributes ('<div ${string}>' or '<div ...string>') is deprecated, use an object instead."
39
+ );
40
+ }
11
41
 
12
- for (var i = arguments.length, last = i - 1; i--; ) {
13
- var source = arguments[i];
14
- for (var k in source) {
15
- if (i === last || !seen.has(k)) {
16
- result += dynamicAttrHelper(k, source[k]);
17
- seen.add(k);
42
+ result += arg[0] === " " ? arg : " " + arg;
43
+ } else {
44
+ for (attrName in arg) {
45
+ if (!seen.has(attrName)) {
46
+ result += dynamicAttrHelper(attrName, arg[attrName]);
47
+ seen.add(attrName);
48
+ }
18
49
  }
19
50
  }
20
51
  }
@@ -15,7 +15,7 @@ runtime.t = function (typeName) {
15
15
  },
16
16
  set: function (v) {
17
17
  renderFn = v;
18
- }
18
+ },
19
19
  });
20
20
 
21
21
  return template;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  globalThis.Marko = {
4
- Component: function () {}
4
+ Component: function () {},
5
5
  };
6
6
 
7
7
  /**
@@ -15,7 +15,7 @@ exports.t = function createTemplate(typeName) {
15
15
  };
16
16
 
17
17
  function Template(typeName) {
18
- this.___typeName = typeName;
18
+ this.path = this.___typeName = typeName;
19
19
  }
20
20
 
21
21
  Template.prototype.stream = require("@internal/create-readable");
@@ -1,3 +1,5 @@
1
+ "use strict";
2
+
1
3
  var defaultCreateOut = require("./createOut");
2
4
  var setImmediate = require("@internal/set-immediate").___setImmediate;
3
5
  var extend = require("raptor-util/extend");
@@ -27,6 +29,7 @@ module.exports = function (target, renderer) {
27
29
  var createOut = target.createOut || renderer.createOut || defaultCreateOut;
28
30
 
29
31
  return extend(target, {
32
+ _: renderFunc,
30
33
  createOut: createOut,
31
34
 
32
35
  renderToString: function (data, callback) {
@@ -127,7 +130,7 @@ module.exports = function (target, renderer) {
127
130
  if (callback) {
128
131
  finalOut
129
132
  .on("finish", function () {
130
- callback(null, finalOut.___getResult());
133
+ callback(null, finalOut.___getResult(), finalOut);
131
134
  })
132
135
  .once("error", callback);
133
136
  }
@@ -137,6 +140,6 @@ module.exports = function (target, renderer) {
137
140
  globalData.template = globalData.template || this;
138
141
 
139
142
  return safeRender(render, finalData, finalOut, shouldEnd);
140
- }
143
+ },
141
144
  });
142
145
  };
@@ -288,7 +288,7 @@ var proto = (AsyncVDOMBuilder.prototype = {
288
288
 
289
289
  state.___events.emit("beginAsync", {
290
290
  out: asyncOut,
291
- parentOut: this
291
+ parentOut: this,
292
292
  });
293
293
 
294
294
  return asyncOut;
@@ -438,7 +438,7 @@ var proto = (AsyncVDOMBuilder.prototype = {
438
438
  this.___assignedComponentDef = componentDef;
439
439
  this.___assignedKey = key;
440
440
  this.___assignedCustomEvents = customEvents;
441
- }
441
+ },
442
442
  });
443
443
 
444
444
  proto.e = proto.element;
@@ -9,7 +9,7 @@ function VComponent(component, key, ownerComponent, preserve) {
9
9
  }
10
10
 
11
11
  VComponent.prototype = {
12
- ___nodeType: 2
12
+ ___nodeType: 2,
13
13
  };
14
14
 
15
15
  inherit(VComponent, VNode);
@@ -24,7 +24,7 @@ VDocumentFragment.prototype = {
24
24
 
25
25
  ___actualize: function (host) {
26
26
  return (host.ownerDocument || host).createDocumentFragment();
27
- }
27
+ },
28
28
  };
29
29
 
30
30
  inherit(VDocumentFragment, VNode);
@@ -1,5 +1,6 @@
1
1
  /* jshint newcap:false */
2
2
 
3
+ var complain = "MARKO_DEBUG" && require("complain");
3
4
  var domData = require("../components/dom-data");
4
5
  var componentsUtil = require("@internal/components-util");
5
6
  var vElementByDOMNode = domData.___vElementByDOMNode;
@@ -14,7 +15,7 @@ var NS_MATH = "http://www.w3.org/1998/Math/MathML";
14
15
  var NS_SVG = "http://www.w3.org/2000/svg";
15
16
  var DEFAULT_NS = {
16
17
  svg: NS_SVG,
17
- math: NS_MATH
18
+ math: NS_MATH,
18
19
  };
19
20
 
20
21
  var FLAG_SIMPLE_ATTRS = 1;
@@ -30,8 +31,18 @@ function convertAttrValue(type, value) {
30
31
  if (value === true) {
31
32
  return "";
32
33
  } else if (type == "object") {
33
- if (value instanceof RegExp) {
34
- return value.source;
34
+ switch (value.toString) {
35
+ case Object.prototype.toString:
36
+ case Array.prototype.toString:
37
+ // eslint-disable-next-line no-constant-condition
38
+ if ("MARKO_DEBUG") {
39
+ complain(
40
+ "Relying on JSON.stringify for attribute values is deprecated, in future versions of Marko these will be cast to strings instead."
41
+ );
42
+ }
43
+ return JSON.stringify(value);
44
+ case RegExp.prototype.toString:
45
+ return value.source;
35
46
  }
36
47
  }
37
48
 
@@ -201,7 +212,7 @@ VElement.prototype = {
201
212
  // different namespaces
202
213
  var value = this.___attributes[name];
203
214
  return value != null && value !== false;
204
- }
215
+ },
205
216
  };
206
217
 
207
218
  inherit(VElement, VNode);
@@ -213,7 +224,7 @@ var proto = (VElementClone.prototype = VElement.prototype);
213
224
  get: function () {
214
225
  var value = this.___attributes[name];
215
226
  return value !== false && value != null;
216
- }
227
+ },
217
228
  });
218
229
  });
219
230
 
@@ -229,7 +240,7 @@ defineProperty(proto, "___value", {
229
240
  this.___attributes.type === "radio"
230
241
  ? "on"
231
242
  : "";
232
- }
243
+ },
233
244
  });
234
245
 
235
246
  VElement.___removePreservedAttributes = function (attrs) {
@@ -18,7 +18,7 @@ VFragment.prototype = {
18
18
  keysByDOMNode.set(fragment, this.___key);
19
19
  vElementByDOMNode.set(fragment, this);
20
20
  return fragment;
21
- }
21
+ },
22
22
  };
23
23
 
24
24
  inherit(VFragment, VNode);
@@ -80,7 +80,7 @@ VNode.prototype = {
80
80
  } else {
81
81
  return this;
82
82
  }
83
- }
83
+ },
84
84
 
85
85
  // ,toJSON: function() {
86
86
  // var clone = Object.assign({
@@ -17,7 +17,7 @@ VText.prototype = {
17
17
 
18
18
  ___cloneNode: function () {
19
19
  return new VText(this.___nodeValue);
20
- }
20
+ },
21
21
  };
22
22
 
23
23
  inherit(VText, VNode);
@@ -1,22 +1,25 @@
1
1
  "use strict";
2
2
 
3
+ var complain = "MARKO_DEBUG" && require("complain");
3
4
  var classHelper = require("../../helpers/class-value");
4
5
  var styleHelper = require("../../helpers/style-value");
6
+ var parseHTML = require("../parse-html");
5
7
 
6
8
  /**
7
9
  * Helper for processing dynamic attributes
8
10
  */
9
11
  module.exports = function (attributes) {
10
- if (attributes != null) {
12
+ if (typeof attributes === "string") {
11
13
  // eslint-disable-next-line no-constant-condition
12
14
  if ("MARKO_DEBUG") {
13
- if (typeof attributes !== "object") {
14
- throw new Error(
15
- "A non object was passed as a dynamic attributes value."
16
- );
17
- }
15
+ complain(
16
+ "Passing a string as a dynamic attribute value is deprecated - More details: https://github.com/marko-js/marko/wiki/Deprecation:-String-as-dynamic-attribute-value"
17
+ );
18
18
  }
19
+ return parseAttrs(attributes);
20
+ }
19
21
 
22
+ if (attributes) {
20
23
  var newAttributes = {};
21
24
 
22
25
  for (var attrName in attributes) {
@@ -39,3 +42,20 @@ module.exports = function (attributes) {
39
42
 
40
43
  return attributes;
41
44
  };
45
+
46
+ function parseAttrs(str) {
47
+ if (str === "") {
48
+ return {};
49
+ }
50
+
51
+ var attrs = parseHTML("<a " + str + ">").attributes;
52
+ var result = {};
53
+ var attr;
54
+
55
+ for (var len = attrs.length, i = 0; i < len; i++) {
56
+ attr = attrs[i];
57
+ result[attr.name] = attr.value;
58
+ }
59
+
60
+ return result;
61
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ var attrs = require("./attrs");
4
+
5
+ /**
6
+ * Merges attribute objects into a object.
7
+ */
8
+ module.exports = function mergeAttrs() {
9
+ var len = arguments.length;
10
+ var result = {};
11
+ for (var i = 0; i < len; i++) {
12
+ Object.assign(result, attrs(arguments[i]));
13
+ }
14
+
15
+ return result;
16
+ };
@@ -61,7 +61,7 @@ runtime.t = function (typeName) {
61
61
  });
62
62
  });
63
63
  }
64
- }
64
+ },
65
65
  });
66
66
 
67
67
  return template;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  window.Marko = {
4
- Component: function () {}
4
+ Component: function () {},
5
5
  };
6
6
 
7
7
  /**
@@ -15,7 +15,7 @@ exports.t = function createTemplate(typeName) {
15
15
  };
16
16
 
17
17
  function Template(typeName) {
18
- this.___typeName = typeName;
18
+ this.path = this.___typeName = typeName;
19
19
  }
20
20
 
21
21
  var AsyncVDOMBuilder = require("./AsyncVDOMBuilder");
@@ -55,7 +55,7 @@ var fragmentPrototype = {
55
55
  this.nodes.forEach(function (node) {
56
56
  this.detachedContainer.appendChild(node);
57
57
  }, this);
58
- }
58
+ },
59
59
  };
60
60
 
61
61
  function createFragmentNode(startNode, nextNode, parentNode) {
@@ -100,7 +100,7 @@ SpecialElHandlers.prototype = {
100
100
  fromEl.selectedIndex = selected;
101
101
  }
102
102
  }
103
- }
103
+ },
104
104
  };
105
105
 
106
106
  module.exports = new SpecialElHandlers();
@@ -46,5 +46,5 @@ exports.lookup = {
46
46
  } else {
47
47
  register(taglib, taglib.id);
48
48
  }
49
- }
49
+ },
50
50
  };
package/tags-html.d.ts CHANGED
@@ -186,6 +186,7 @@ declare global {
186
186
  | "prev"
187
187
  | "search"
188
188
  | "tag"
189
+ // eslint-disable-next-line @typescript-eslint/ban-types
189
190
  | (string & {});
190
191
 
191
192
  /**
@@ -313,6 +314,7 @@ declare global {
313
314
  | "nofullscreen"
314
315
  | "noplaybackrate"
315
316
  | "noremoteplayback"
317
+ // eslint-disable-next-line @typescript-eslint/ban-types
316
318
  | (string & {});
317
319
 
318
320
  /**
@@ -816,6 +818,7 @@ declare global {
816
818
  | "opener"
817
819
  | "prev"
818
820
  | "search"
821
+ // eslint-disable-next-line @typescript-eslint/ban-types
819
822
  | (string & {});
820
823
  /**
821
824
  * Specifies the browsing context in which the linked resource will be opened.
@@ -925,6 +928,7 @@ declare global {
925
928
  | "allow-top-navigation-by-user-activation"
926
929
  | "allow-top-navigation-to-custom-protocols"
927
930
  | "allow-top-navigation"
931
+ // eslint-disable-next-line @typescript-eslint/ban-types
928
932
  | (string & {});
929
933
  /**
930
934
  * The URL of the page to embed in the iframe.
@@ -1429,6 +1433,7 @@ declare global {
1429
1433
  | "prev"
1430
1434
  | "search"
1431
1435
  | "stylesheet"
1436
+ // eslint-disable-next-line @typescript-eslint/ban-types
1432
1437
  | (string & {});
1433
1438
 
1434
1439
  /**
@@ -1779,6 +1784,7 @@ declare global {
1779
1784
  | "application/javascript"
1780
1785
  | "module"
1781
1786
  | "import-map"
1787
+ // eslint-disable-next-line @typescript-eslint/ban-types
1782
1788
  | (string & {});
1783
1789
 
1784
1790
  /** @deprecated */
@@ -2236,6 +2242,7 @@ declare global {
2236
2242
  | "nofullscreen"
2237
2243
  | "noplaybackrate"
2238
2244
  | "noremoteplayback"
2245
+ // eslint-disable-next-line @typescript-eslint/ban-types
2239
2246
  | (string & {});
2240
2247
 
2241
2248
  /**
@@ -3913,6 +3920,7 @@ type AttrTarget =
3913
3920
  | "_parent"
3914
3921
  | "_self"
3915
3922
  | "_top"
3923
+ // eslint-disable-next-line @typescript-eslint/ban-types
3916
3924
  | (string & {});
3917
3925
  type AttrReferrerPolicy =
3918
3926
  | AttrMissing
@@ -3985,6 +3993,7 @@ type AttrAutoComplete =
3985
3993
  | "mobile"
3986
3994
  | "fax"
3987
3995
  | "pager"
3996
+ // eslint-disable-next-line @typescript-eslint/ban-types
3988
3997
  | (string & {});
3989
3998
  type Tag<Input> = Input extends Marko.HTMLAttributes<infer Element>
3990
3999
  ? Marko.NativeTag<Input, Element>