marko 4.24.6 → 4.26.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (317) hide show
  1. package/bin/markoc.js +18 -18
  2. package/dist/compiler/CompileContext.js +3 -8
  3. package/dist/core-tags/components/init-components-tag.js +1 -52
  4. package/dist/core-tags/components/package.json +1 -3
  5. package/dist/core-tags/components/preferred-script-location-tag.js +2 -2
  6. package/dist/core-tags/components/preserve-tag.js +1 -27
  7. package/dist/core-tags/core/await/AsyncValue.js +20 -20
  8. package/dist/core-tags/core/await/renderer.js +11 -12
  9. package/dist/core-tags/core/await/reorderer-renderer.js +11 -6
  10. package/dist/index.js +1 -39
  11. package/dist/node-require/index.js +11 -0
  12. package/dist/node_modules/@internal/components-beginComponent/index-browser.js +12 -0
  13. package/dist/{runtime/components/beginComponent.js → node_modules/@internal/components-beginComponent/index.js} +14 -14
  14. package/dist/node_modules/@internal/components-beginComponent/package.json +11 -0
  15. package/dist/{runtime/components/legacy/defineWidget-legacy-browser.js → node_modules/@internal/components-define-widget-legacy/index-browser.js} +47 -47
  16. package/dist/node_modules/@internal/components-define-widget-legacy/index.js +18 -0
  17. package/dist/node_modules/@internal/components-define-widget-legacy/package.json +11 -0
  18. package/dist/node_modules/@internal/components-endComponent/index.js +11 -0
  19. package/dist/node_modules/@internal/components-endComponent/package.json +11 -0
  20. package/dist/node_modules/@internal/components-entry/index-browser.js +9 -0
  21. package/dist/node_modules/@internal/components-entry/index.js +285 -0
  22. package/dist/node_modules/@internal/components-entry/package.json +11 -0
  23. package/dist/{runtime/components/legacy → node_modules/@internal/components-entry-legacy}/index-browser.js +14 -15
  24. package/dist/node_modules/@internal/components-entry-legacy/index.js +14 -0
  25. package/dist/node_modules/@internal/components-entry-legacy/package.json +11 -0
  26. package/dist/{runtime/components/init-components-browser.js → node_modules/@internal/components-registry/index-browser.js} +180 -79
  27. package/dist/node_modules/@internal/components-registry/index.js +34 -0
  28. package/dist/node_modules/@internal/components-registry/package.json +11 -0
  29. package/dist/{runtime/components/util-browser.js → node_modules/@internal/components-util/index-browser.js} +23 -24
  30. package/dist/{runtime/components/util.js → node_modules/@internal/components-util/index.js} +10 -12
  31. package/dist/node_modules/@internal/components-util/package.json +11 -0
  32. package/dist/node_modules/@internal/create-readable/index-browser.js +25 -0
  33. package/dist/node_modules/@internal/create-readable/index.js +52 -0
  34. package/dist/node_modules/@internal/create-readable/package.json +11 -0
  35. package/dist/node_modules/@internal/init-components-tag/index.js +52 -0
  36. package/dist/node_modules/@internal/init-components-tag/package.json +11 -0
  37. package/dist/{loader/index-default.js → node_modules/@internal/loader/index.js} +1 -1
  38. package/dist/node_modules/@internal/loader/package.json +11 -0
  39. package/dist/{core-tags/components/preserve-tag-browser.js → node_modules/@internal/preserve-tag/index-browser.js} +8 -8
  40. package/dist/node_modules/@internal/preserve-tag/index.js +27 -0
  41. package/dist/node_modules/@internal/preserve-tag/package.json +11 -0
  42. package/dist/node_modules/@internal/set-immediate/index-browser.js +17 -0
  43. package/dist/node_modules/@internal/set-immediate/index-worker.js +2 -0
  44. package/dist/node_modules/@internal/set-immediate/index.js +2 -0
  45. package/dist/node_modules/@internal/set-immediate/package.json +11 -0
  46. package/dist/runtime/RenderResult.js +24 -19
  47. package/dist/runtime/components/Component.js +154 -151
  48. package/dist/runtime/components/ComponentDef.js +28 -28
  49. package/dist/runtime/components/ComponentsContext.js +19 -19
  50. package/dist/runtime/components/GlobalComponentsContext.js +4 -4
  51. package/dist/runtime/components/KeySequence.js +3 -3
  52. package/dist/runtime/components/ServerComponent.js +13 -13
  53. package/dist/runtime/components/State.js +28 -28
  54. package/dist/runtime/components/attach-detach.js +9 -9
  55. package/dist/runtime/components/defineComponent.js +5 -5
  56. package/dist/runtime/components/dom-data.js +6 -6
  57. package/dist/runtime/components/event-delegation.js +15 -16
  58. package/dist/runtime/components/index.js +1 -285
  59. package/dist/runtime/components/legacy/browser.json +1 -1
  60. package/dist/runtime/components/legacy/defineComponent-legacy.js +1 -1
  61. package/dist/runtime/components/legacy/defineRenderer-legacy.js +18 -19
  62. package/dist/runtime/components/legacy/defineWidget-legacy.js +1 -18
  63. package/dist/runtime/components/legacy/dependencies/html.js +1 -1
  64. package/dist/runtime/components/legacy/dependencies/index.js +9 -9
  65. package/dist/runtime/components/legacy/helper-getWidgetFromOut.js +3 -3
  66. package/dist/runtime/components/legacy/index.js +1 -14
  67. package/dist/runtime/components/legacy/renderer-legacy.js +43 -43
  68. package/dist/runtime/components/registry.js +1 -34
  69. package/dist/runtime/components/renderer.js +38 -38
  70. package/dist/runtime/components/update-manager.js +10 -10
  71. package/dist/runtime/createOut.js +1 -1
  72. package/dist/runtime/dom-insert.js +6 -6
  73. package/dist/runtime/helpers/_change-case.js +2 -2
  74. package/dist/runtime/helpers/assign.js +3 -2
  75. package/dist/runtime/helpers/dynamic-tag.js +14 -16
  76. package/dist/runtime/helpers/load-template.js +1 -1
  77. package/dist/runtime/helpers/merge.js +3 -1
  78. package/dist/runtime/helpers/style-value.js +2 -2
  79. package/dist/runtime/html/AsyncStream.js +61 -52
  80. package/dist/runtime/html/BufferedWriter.js +5 -1
  81. package/dist/runtime/html/StringWriter.js +7 -3
  82. package/dist/runtime/html/helpers/_dynamic-attr.js +2 -2
  83. package/dist/runtime/html/helpers/attr.js +4 -4
  84. package/dist/runtime/html/helpers/attrs.js +3 -3
  85. package/dist/runtime/html/helpers/data-marko.js +4 -6
  86. package/dist/runtime/html/helpers/escape-quotes.js +2 -2
  87. package/dist/runtime/html/helpers/escape-xml.js +1 -1
  88. package/dist/runtime/html/helpers/props-script.js +1 -1
  89. package/dist/runtime/html/index.js +15 -12
  90. package/dist/runtime/renderable.js +5 -5
  91. package/dist/runtime/vdom/AsyncVDOMBuilder.js +102 -103
  92. package/dist/runtime/vdom/VComment.js +7 -7
  93. package/dist/runtime/vdom/VComponent.js +5 -5
  94. package/dist/runtime/vdom/VDocumentFragment.js +8 -8
  95. package/dist/runtime/vdom/VElement.js +55 -54
  96. package/dist/runtime/vdom/VFragment.js +9 -9
  97. package/dist/runtime/vdom/VNode.js +30 -30
  98. package/dist/runtime/vdom/VText.js +7 -7
  99. package/dist/runtime/vdom/helpers/v-element.js +1 -1
  100. package/dist/runtime/vdom/helpers/v-text.js +1 -1
  101. package/dist/runtime/vdom/index.js +12 -22
  102. package/dist/runtime/vdom/morphdom/fragment.js +5 -5
  103. package/dist/runtime/vdom/morphdom/helpers.js +3 -3
  104. package/dist/runtime/vdom/morphdom/index.js +72 -68
  105. package/dist/runtime/vdom/morphdom/specialElHandlers.js +8 -8
  106. package/dist/runtime/vdom/preserve-attrs.js +1 -1
  107. package/dist/runtime/vdom/vdom.js +19 -21
  108. package/docs/body-content.md +2 -2
  109. package/docs/class-components.md +3 -3
  110. package/docs/express.md +1 -1
  111. package/docs/lasso.md +3 -6
  112. package/docs/marko-v4.md +5 -5
  113. package/docs/redux.md +1 -1
  114. package/docs/server-side-rendering.md +2 -2
  115. package/docs/why-is-marko-fast.md +2 -10
  116. package/package.json +4 -4
  117. package/src/browser-refresh.js +2 -2
  118. package/src/compiler/CodeWriter.js +1 -3
  119. package/src/compiler/CompileContext.js +3 -8
  120. package/src/compiler/Compiler.js +4 -4
  121. package/src/compiler/HtmlJsParser.js +1 -1
  122. package/src/compiler/Migrator.js +1 -1
  123. package/src/compiler/Parser.js +3 -3
  124. package/src/compiler/ast/CustomTag.js +9 -11
  125. package/src/compiler/ast/HtmlAttribute/html/generateCode.js +2 -2
  126. package/src/compiler/ast/HtmlAttribute/index.js +1 -1
  127. package/src/compiler/ast/HtmlElement/vdom/HtmlElementVDOM.js +1 -1
  128. package/src/compiler/ast/HtmlElement/vdom/generateCode.js +1 -1
  129. package/src/compiler/ast/TemplateRoot.js +1 -1
  130. package/src/compiler/ast/Text/html/generateCode.js +3 -3
  131. package/src/compiler/ast/Text/vdom/generateCode.js +1 -1
  132. package/src/compiler/index.js +4 -4
  133. package/src/compiler/modules.js +4 -4
  134. package/src/compiler/util/finger-print.js +1 -1
  135. package/src/compiler/util/parseExpression.js +1 -1
  136. package/src/compiler/util/parseStatement.js +1 -1
  137. package/src/compiler/util/removeDashes.js +1 -1
  138. package/src/compiler/util/safeVarName.js +1 -1
  139. package/src/compiler/util/tokenizer.js +1 -1
  140. package/src/core-tags/cache/cached-fragment-tag-transformer.js +1 -1
  141. package/src/core-tags/cache/cached-fragment-tag.js +4 -4
  142. package/src/core-tags/cache/default-cache-manager.js +3 -3
  143. package/src/core-tags/components/TransformHelper/ComponentArgsCompiler.js +1 -1
  144. package/src/core-tags/components/TransformHelper/convertToComponent.js +1 -1
  145. package/src/core-tags/components/TransformHelper/handleComponentPreserveAttrs.js +1 -1
  146. package/src/core-tags/components/init-components-tag.js +1 -54
  147. package/src/core-tags/components/package.json +1 -3
  148. package/src/core-tags/components/preferred-script-location-tag.js +1 -1
  149. package/src/core-tags/components/preserve-tag.js +1 -27
  150. package/src/core-tags/components/util/getTransformHelper.js +1 -1
  151. package/src/core-tags/core/await/AsyncValue.js +3 -3
  152. package/src/core-tags/core/await/noop-render.js +1 -1
  153. package/src/core-tags/core/await/renderer.js +8 -7
  154. package/src/core-tags/core/await/reorderer-renderer.js +35 -14
  155. package/src/core-tags/core/await/transformer.js +1 -1
  156. package/src/core-tags/core/core-transformer.js +2 -2
  157. package/src/core-tags/migrate/all-tags/index.js +1 -1
  158. package/src/core-tags/migrate/all-templates/index.js +1 -1
  159. package/src/core-tags/migrate/include-tag.js +3 -2
  160. package/src/core-tags/migrate/util/parseFor.js +3 -2
  161. package/src/core-tags/migrate/util/printJS.js +1 -1
  162. package/src/defineRenderer.js +1 -1
  163. package/src/express.js +1 -1
  164. package/src/hot-reload.js +5 -5
  165. package/src/index.js +1 -41
  166. package/src/legacy-helpers/notEmpty.js +1 -1
  167. package/src/node-require/index.js +12 -1
  168. package/src/{runtime/components/beginComponent-browser.js → node_modules/@internal/components-beginComponent/index-browser.js} +1 -1
  169. package/src/{runtime/components/beginComponent.js → node_modules/@internal/components-beginComponent/index.js} +2 -2
  170. package/src/node_modules/@internal/components-beginComponent/package.json +11 -0
  171. package/src/{runtime/components/legacy/defineWidget-legacy-browser.js → node_modules/@internal/components-define-widget-legacy/index-browser.js} +21 -23
  172. package/src/node_modules/@internal/components-define-widget-legacy/index.js +18 -0
  173. package/src/node_modules/@internal/components-define-widget-legacy/package.json +11 -0
  174. package/src/{runtime/components/endComponent.js → node_modules/@internal/components-endComponent/index.js} +1 -1
  175. package/src/node_modules/@internal/components-endComponent/package.json +11 -0
  176. package/src/node_modules/@internal/components-entry/index-browser.js +9 -0
  177. package/src/node_modules/@internal/components-entry/index.js +301 -0
  178. package/src/node_modules/@internal/components-entry/package.json +11 -0
  179. package/src/node_modules/@internal/components-entry-legacy/index-browser.js +74 -0
  180. package/src/node_modules/@internal/components-entry-legacy/index.js +15 -0
  181. package/src/node_modules/@internal/components-entry-legacy/package.json +11 -0
  182. package/src/{runtime/components/init-components-browser.js → node_modules/@internal/components-registry/index-browser.js} +240 -75
  183. package/src/node_modules/@internal/components-registry/index.js +44 -0
  184. package/src/node_modules/@internal/components-registry/package.json +11 -0
  185. package/src/{runtime/components/util-browser.js → node_modules/@internal/components-util/index-browser.js} +11 -10
  186. package/src/{runtime/components/util.js → node_modules/@internal/components-util/index.js} +0 -2
  187. package/src/node_modules/@internal/components-util/package.json +11 -0
  188. package/src/node_modules/@internal/create-readable/index-browser.js +30 -0
  189. package/src/node_modules/@internal/create-readable/index.js +57 -0
  190. package/src/node_modules/@internal/create-readable/package.json +11 -0
  191. package/src/node_modules/@internal/init-components-tag/index.js +54 -0
  192. package/src/node_modules/@internal/init-components-tag/package.json +11 -0
  193. package/src/{loader/index-default.js → node_modules/@internal/loader/index.js} +2 -2
  194. package/src/node_modules/@internal/loader/package.json +11 -0
  195. package/src/node_modules/@internal/preserve-tag/index.js +27 -0
  196. package/src/node_modules/@internal/preserve-tag/package.json +11 -0
  197. package/src/node_modules/@internal/set-immediate/index-browser.js +17 -0
  198. package/src/node_modules/@internal/set-immediate/index-worker.js +2 -0
  199. package/src/node_modules/@internal/set-immediate/index.js +2 -0
  200. package/src/node_modules/@internal/set-immediate/package.json +11 -0
  201. package/src/runtime/RenderResult.js +20 -18
  202. package/src/runtime/components/Component.js +44 -41
  203. package/src/runtime/components/ComponentDef.js +9 -9
  204. package/src/runtime/components/ComponentsContext.js +4 -5
  205. package/src/runtime/components/GlobalComponentsContext.js +2 -1
  206. package/src/runtime/components/KeySequence.js +1 -1
  207. package/src/runtime/components/State.js +6 -6
  208. package/src/runtime/components/attach-detach.js +4 -4
  209. package/src/runtime/components/defineComponent.js +1 -1
  210. package/src/runtime/components/event-delegation.js +10 -10
  211. package/src/runtime/components/index.js +1 -301
  212. package/src/runtime/components/jquery.js +2 -2
  213. package/src/runtime/components/legacy/browser.json +1 -1
  214. package/src/runtime/components/legacy/defineRenderer-legacy.js +5 -6
  215. package/src/runtime/components/legacy/defineWidget-legacy.js +1 -18
  216. package/src/runtime/components/legacy/dependencies/html.js +1 -1
  217. package/src/runtime/components/legacy/dependencies/index.js +3 -3
  218. package/src/runtime/components/legacy/helper-getWidgetFromOut.js +3 -3
  219. package/src/runtime/components/legacy/index.js +1 -15
  220. package/src/runtime/components/legacy/renderer-legacy.js +7 -7
  221. package/src/runtime/components/ready.js +2 -2
  222. package/src/runtime/components/registry.js +1 -44
  223. package/src/runtime/components/renderer.js +4 -4
  224. package/src/runtime/components/update-manager.js +1 -1
  225. package/src/runtime/dom-insert.js +8 -8
  226. package/src/runtime/helpers/_weak-map.js +2 -2
  227. package/src/runtime/helpers/assign.js +3 -1
  228. package/src/runtime/helpers/bind-component.js +2 -2
  229. package/src/runtime/helpers/dynamic-tag.js +2 -4
  230. package/src/runtime/helpers/for-in.js +1 -1
  231. package/src/runtime/helpers/load-nested-tag.js +1 -1
  232. package/src/runtime/helpers/load-template.js +1 -1
  233. package/src/runtime/helpers/merge.js +3 -1
  234. package/src/runtime/helpers/noop.js +1 -1
  235. package/src/runtime/helpers/style-value.js +1 -1
  236. package/src/runtime/helpers/to-string.js +1 -1
  237. package/src/runtime/html/AsyncStream.js +90 -76
  238. package/src/runtime/html/BufferedWriter.js +6 -2
  239. package/src/runtime/html/StringWriter.js +15 -9
  240. package/src/runtime/html/helpers/attrs.js +3 -3
  241. package/src/runtime/html/helpers/data-marko.js +0 -2
  242. package/src/runtime/html/helpers/escape-quotes.js +1 -1
  243. package/src/runtime/html/helpers/escape-xml.js +1 -1
  244. package/src/runtime/html/index.js +23 -13
  245. package/src/runtime/queueMicrotask.js +2 -2
  246. package/src/runtime/renderable.js +9 -9
  247. package/src/runtime/vdom/AsyncVDOMBuilder.js +46 -51
  248. package/src/runtime/vdom/VComment.js +3 -3
  249. package/src/runtime/vdom/VDocumentFragment.js +3 -3
  250. package/src/runtime/vdom/VElement.js +17 -13
  251. package/src/runtime/vdom/VFragment.js +1 -1
  252. package/src/runtime/vdom/VNode.js +2 -2
  253. package/src/runtime/vdom/VText.js +3 -3
  254. package/src/runtime/vdom/helpers/attrs.js +1 -1
  255. package/src/runtime/vdom/helpers/const.js +2 -2
  256. package/src/runtime/vdom/helpers/v-element.js +1 -1
  257. package/src/runtime/vdom/helpers/v-text.js +1 -1
  258. package/src/runtime/vdom/index.js +21 -23
  259. package/src/runtime/vdom/morphdom/fragment.js +8 -7
  260. package/src/runtime/vdom/morphdom/index.js +19 -9
  261. package/src/runtime/vdom/morphdom/specialElHandlers.js +6 -6
  262. package/src/runtime/vdom/parse-html.js +4 -4
  263. package/src/runtime/vdom/preserve-attrs.js +1 -1
  264. package/src/runtime/vdom/vdom.js +5 -7
  265. package/src/taglib/taglib-finder/index.js +1 -1
  266. package/src/taglib/taglib-loader/Tag.js +5 -5
  267. package/src/taglib/taglib-loader/Taglib.js +2 -2
  268. package/src/taglib/taglib-loader/json-file-reader.js +1 -1
  269. package/src/taglib/taglib-loader/loadAttributeFromProps.js +1 -1
  270. package/src/taglib/taglib-loader/loadTagFromProps.js +5 -6
  271. package/src/taglib/taglib-loader/tag-def-from-code.js +2 -1
  272. package/src/taglib/taglib-lookup/TaglibLookup.js +2 -2
  273. package/src/taglib/taglib-lookup/index.js +1 -1
  274. package/dist/core-tags/core/await/client-reorder-browser.js +0 -1
  275. package/dist/core-tags/core/await/client-reorder-runtime.min.js +0 -5
  276. package/dist/core-tags/core/await/client-reorder.js +0 -11
  277. package/dist/core-tags/core/await/package.json +0 -6
  278. package/dist/index-browser.js +0 -4
  279. package/dist/loader/index.js +0 -7
  280. package/dist/loader/package.json +0 -5
  281. package/dist/node-require/index-browser.js +0 -1
  282. package/dist/package.json +0 -5
  283. package/dist/runtime/components/beginComponent-browser.js +0 -12
  284. package/dist/runtime/components/endComponent.js +0 -11
  285. package/dist/runtime/components/index-browser.js +0 -14
  286. package/dist/runtime/components/init-components.js +0 -1
  287. package/dist/runtime/components/legacy/package.json +0 -6
  288. package/dist/runtime/components/package.json +0 -12
  289. package/dist/runtime/components/registry-browser.js +0 -73
  290. package/dist/runtime/html/Template.js +0 -63
  291. package/dist/runtime/package.json +0 -5
  292. package/dist/runtime/setImmediate.js +0 -19
  293. package/src/core-tags/core/await/client-reorder-browser.js +0 -1
  294. package/src/core-tags/core/await/client-reorder-runtime.min.js +0 -1
  295. package/src/core-tags/core/await/client-reorder.js +0 -14
  296. package/src/core-tags/core/await/package.json +0 -6
  297. package/src/index-browser.js +0 -3
  298. package/src/loader/index.js +0 -7
  299. package/src/loader/package.json +0 -5
  300. package/src/node-require/index-browser.js +0 -1
  301. package/src/package.json +0 -5
  302. package/src/runtime/components/index-browser.js +0 -15
  303. package/src/runtime/components/init-components.js +0 -1
  304. package/src/runtime/components/legacy/index-browser.js +0 -73
  305. package/src/runtime/components/legacy/package.json +0 -6
  306. package/src/runtime/components/package.json +0 -12
  307. package/src/runtime/components/registry-browser.js +0 -103
  308. package/src/runtime/html/Template.js +0 -62
  309. package/src/runtime/package.json +0 -5
  310. package/src/runtime/setImmediate.js +0 -21
  311. /package/dist/{runtime/components/endComponent-browser.js → node_modules/@internal/components-endComponent/index-browser.js} +0 -0
  312. /package/dist/{core-tags/components/init-components-tag-browser.js → node_modules/@internal/init-components-tag/index-browser.js} +0 -0
  313. /package/dist/{loader → node_modules/@internal/loader}/index-browser.js +0 -0
  314. /package/src/{runtime/components/endComponent-browser.js → node_modules/@internal/components-endComponent/index-browser.js} +0 -0
  315. /package/src/{core-tags/components/init-components-tag-browser.js → node_modules/@internal/init-components-tag/index-browser.js} +0 -0
  316. /package/src/{loader → node_modules/@internal/loader}/index-browser.js +0 -0
  317. /package/src/{core-tags/components/preserve-tag-browser.js → node_modules/@internal/preserve-tag/index-browser.js} +0 -0
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
- var escapeDoubleQuotes = require("./helpers/escape-quotes")
4
- .___escapeDoubleQuotes;
3
+ var escapeDoubleQuotes =
4
+ require("./helpers/escape-quotes").___escapeDoubleQuotes;
5
5
 
6
6
  function StringWriter() {
7
7
  this._content = "";
@@ -10,24 +10,30 @@ function StringWriter() {
10
10
  }
11
11
 
12
12
  StringWriter.prototype = {
13
- write: function(str) {
13
+ write: function (str) {
14
14
  this._content += str;
15
15
  },
16
16
 
17
- script: function(str) {
17
+ script: function (str) {
18
18
  if (str) {
19
19
  this._scripts += (this._scripts ? ";" : "") + str;
20
20
  }
21
21
  },
22
22
 
23
- get: function(key) {
23
+ get: function (key) {
24
24
  const extra = (this._data = this._data || {});
25
25
  return (extra[key] = extra[key] || []);
26
26
  },
27
27
 
28
- merge: function(otherWriter) {
28
+ merge: function (otherWriter) {
29
29
  this._content += otherWriter._content;
30
- this._scripts += otherWriter._scripts;
30
+
31
+ if (otherWriter._scripts) {
32
+ this._scripts = this._scripts
33
+ ? this._scripts + ";" + otherWriter._scripts
34
+ : otherWriter._scripts;
35
+ }
36
+
31
37
  if (otherWriter._data) {
32
38
  if (this._data) {
33
39
  for (const key in otherWriter._data) {
@@ -43,13 +49,13 @@ StringWriter.prototype = {
43
49
  }
44
50
  },
45
51
 
46
- clear: function() {
52
+ clear: function () {
47
53
  this._content = "";
48
54
  this._scripts = "";
49
55
  this._data = null;
50
56
  },
51
57
 
52
- toString: function() {
58
+ toString: function () {
53
59
  this.state.events.emit("___toString", this);
54
60
  let str = this._content;
55
61
  if (this._scripts) {
@@ -6,11 +6,11 @@ var dynamicAttrHelper = require("./_dynamic-attr");
6
6
  module.exports = function attrs(arg) {
7
7
  switch (typeof arg) {
8
8
  case "object":
9
- var out = "";
9
+ var result = "";
10
10
  for (var attrName in arg) {
11
- out += dynamicAttrHelper(attrName, arg[attrName]);
11
+ result += dynamicAttrHelper(attrName, arg[attrName]);
12
12
  }
13
- return out;
13
+ return result;
14
14
  case "string":
15
15
  // eslint-disable-next-line no-constant-condition
16
16
  if ("MARKO_DEBUG") {
@@ -5,8 +5,6 @@ var escapeSingleQuotes = escapeQuoteHelpers.___escapeSingleQuotes;
5
5
  var escapeDoubleQuotes = escapeQuoteHelpers.___escapeDoubleQuotes;
6
6
  var FLAG_WILL_RERENDER_IN_BROWSER = 1;
7
7
  // var FLAG_HAS_RENDER_BODY = 2;
8
- // var FLAG_IS_LEGACY = 4;
9
- // var FLAG_OLD_HYDRATE_NO_CREATE = 8;
10
8
 
11
9
  module.exports = function dataMarko(out, componentDef, props, key) {
12
10
  var result = "";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- exports.d = function(value) {
3
+ exports.d = function (value) {
4
4
  return escapeDoubleQuotes(value + "", 0);
5
5
  };
6
6
 
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- module.exports.x = function(value) {
3
+ module.exports.x = function (value) {
4
4
  if (value == null) {
5
5
  return "";
6
6
  }
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
 
3
- var Template;
3
+ globalThis.Marko = {
4
+ Component: function () {}
5
+ };
4
6
 
5
7
  /**
6
8
  * Method is for internal usage only. This method
@@ -8,26 +10,34 @@ var Template;
8
10
  * it is used to create a new Template instance.
9
11
  * @private
10
12
  */
11
- exports.t = function createTemplate(path) {
12
- return new Template(path);
13
+ exports.t = function createTemplate(typeName) {
14
+ return new Template(typeName);
13
15
  };
14
16
 
15
- require("../../");
17
+ function Template(typeName) {
18
+ this.path = this.___typeName = typeName;
19
+ }
16
20
 
17
- var AsyncStream = require("./AsyncStream");
18
- Template = require("./Template");
21
+ Template.prototype.stream = require("@internal/create-readable");
19
22
 
20
- function createOut(globalData, parent, state, buffer) {
21
- return new AsyncStream(globalData, parent, state, buffer);
22
- }
23
+ var AsyncStream = require("./AsyncStream");
23
24
 
24
- exports.createWriter = function(writer) {
25
+ exports.createWriter = function (writer) {
25
26
  return new AsyncStream(null, writer);
26
27
  };
27
-
28
28
  exports.Template = Template;
29
- exports.___createOut = createOut;
30
29
  exports.AsyncStream = AsyncStream;
31
30
  exports.enableAsyncStackTrace = AsyncStream.enableAsyncStackTrace;
32
31
 
33
- require("../createOut").___setCreateOut(createOut);
32
+ require("../createOut").___setCreateOut(
33
+ (Template.prototype.createOut = function createOut(
34
+ globalData,
35
+ writer,
36
+ parentOut,
37
+ buffer
38
+ ) {
39
+ return new AsyncStream(globalData, writer, parentOut, buffer);
40
+ })
41
+ );
42
+
43
+ require("../renderable")(Template.prototype);
@@ -3,12 +3,12 @@ module.exports =
3
3
  typeof queueMicrotask === "function"
4
4
  ? queueMicrotask
5
5
  : typeof Promise === "function" && (promise = Promise.resolve())
6
- ? function(cb) {
6
+ ? function (cb) {
7
7
  promise.then(cb).catch(rethrow);
8
8
  }
9
9
  : setTimeout;
10
10
  function rethrow(err) {
11
- setTimeout(function() {
11
+ setTimeout(function () {
12
12
  throw err;
13
13
  });
14
14
  }
@@ -1,5 +1,5 @@
1
1
  var defaultCreateOut = require("./createOut");
2
- var setImmediate = require("./setImmediate");
2
+ var setImmediate = require("@internal/set-immediate").___setImmediate;
3
3
  var extend = require("raptor-util/extend");
4
4
 
5
5
  function safeRender(renderFunc, finalData, finalOut, shouldEnd) {
@@ -11,9 +11,9 @@ function safeRender(renderFunc, finalData, finalOut, shouldEnd) {
11
11
  }
12
12
  } catch (err) {
13
13
  var actualEnd = finalOut.end;
14
- finalOut.end = function() {};
14
+ finalOut.end = function () {};
15
15
 
16
- setImmediate(function() {
16
+ setImmediate(function () {
17
17
  finalOut.end = actualEnd;
18
18
  finalOut.error(err);
19
19
  });
@@ -21,7 +21,7 @@ function safeRender(renderFunc, finalData, finalOut, shouldEnd) {
21
21
  return finalOut;
22
22
  }
23
23
 
24
- module.exports = function(target, renderer) {
24
+ module.exports = function (target, renderer) {
25
25
  var renderFunc =
26
26
  renderer && (renderer.renderer || renderer.render || renderer);
27
27
  var createOut = target.createOut || renderer.createOut || defaultCreateOut;
@@ -29,7 +29,7 @@ module.exports = function(target, renderer) {
29
29
  return extend(target, {
30
30
  createOut: createOut,
31
31
 
32
- renderToString: function(data, callback) {
32
+ renderToString: function (data, callback) {
33
33
  var localData = data || {};
34
34
  var render = renderFunc || this._;
35
35
  var globalData = localData.$global;
@@ -43,7 +43,7 @@ module.exports = function(target, renderer) {
43
43
 
44
44
  if (callback) {
45
45
  out
46
- .on("finish", function() {
46
+ .on("finish", function () {
47
47
  callback(null, out.toString(), out);
48
48
  })
49
49
  .once("error", callback);
@@ -56,7 +56,7 @@ module.exports = function(target, renderer) {
56
56
  }
57
57
  },
58
58
 
59
- renderSync: function(data) {
59
+ renderSync: function (data) {
60
60
  var localData = data || {};
61
61
  var render = renderFunc || this._;
62
62
  var globalData = localData.$global;
@@ -90,7 +90,7 @@ module.exports = function(target, renderer) {
90
90
  * @param {AsyncStream/AsyncVDOMBuilder} out A Stream, an AsyncStream/AsyncVDOMBuilder instance, or a callback function
91
91
  * @return {AsyncStream/AsyncVDOMBuilder} Returns the AsyncStream/AsyncVDOMBuilder instance that the template is rendered to
92
92
  */
93
- render: function(data, out) {
93
+ render: function (data, out) {
94
94
  var callback;
95
95
  var finalOut;
96
96
  var finalData;
@@ -126,7 +126,7 @@ module.exports = function(target, renderer) {
126
126
 
127
127
  if (callback) {
128
128
  finalOut
129
- .on("finish", function() {
129
+ .on("finish", function () {
130
130
  callback(null, finalOut.___getResult(), finalOut);
131
131
  })
132
132
  .once("error", callback);
@@ -8,7 +8,6 @@ var VComponent = vdom.___VComponent;
8
8
  var VFragment = vdom.___VFragment;
9
9
  var virtualizeHTML = vdom.___virtualizeHTML;
10
10
  var RenderResult = require("../RenderResult");
11
- var defaultDocument = vdom.___defaultDocument;
12
11
  var morphdom = require("./morphdom");
13
12
  var attrsHelper = require("./helpers/attrs");
14
13
 
@@ -55,19 +54,19 @@ function AsyncVDOMBuilder(globalData, parentNode, parentOut) {
55
54
 
56
55
  var proto = (AsyncVDOMBuilder.prototype = {
57
56
  ___isOut: true,
58
- ___document: defaultDocument,
57
+ ___host: typeof document === "object" && document,
59
58
 
60
- bc: function(component, key, ownerComponent) {
59
+ bc: function (component, key, ownerComponent) {
61
60
  var vComponent = new VComponent(component, key, ownerComponent);
62
61
  return this.___beginNode(vComponent, 0, true);
63
62
  },
64
63
 
65
- ___preserveComponent: function(component, key, ownerComponent) {
64
+ ___preserveComponent: function (component, key, ownerComponent) {
66
65
  var vComponent = new VComponent(component, key, ownerComponent, true);
67
66
  this.___beginNode(vComponent, 0);
68
67
  },
69
68
 
70
- ___beginNode: function(child, childCount, pushToStack) {
69
+ ___beginNode: function (child, childCount, pushToStack) {
71
70
  this.___parent.___appendChild(child);
72
71
  if (pushToStack === true) {
73
72
  this.___stack.push(child);
@@ -76,7 +75,7 @@ var proto = (AsyncVDOMBuilder.prototype = {
76
75
  return childCount === 0 ? this : child;
77
76
  },
78
77
 
79
- element: function(tagName, attrs, key, component, childCount, flags, props) {
78
+ element: function (tagName, attrs, key, component, childCount, flags, props) {
80
79
  var element = new VElement(
81
80
  tagName,
82
81
  attrs,
@@ -89,7 +88,7 @@ var proto = (AsyncVDOMBuilder.prototype = {
89
88
  return this.___beginNode(element, childCount);
90
89
  },
91
90
 
92
- ___elementDynamic: function(tagName, attrs, key, componentDef, props) {
91
+ ___elementDynamic: function (tagName, attrs, key, componentDef, props) {
93
92
  return this.element(
94
93
  tagName,
95
94
  attrsHelper(attrs),
@@ -101,7 +100,7 @@ var proto = (AsyncVDOMBuilder.prototype = {
101
100
  );
102
101
  },
103
102
 
104
- n: function(node, component) {
103
+ n: function (node, component) {
105
104
  // NOTE: We do a shallow clone since we assume the node is being reused
106
105
  // and a node can only have one parent node.
107
106
  var clone = node.___cloneNode();
@@ -111,12 +110,12 @@ var proto = (AsyncVDOMBuilder.prototype = {
111
110
  return this;
112
111
  },
113
112
 
114
- node: function(node) {
113
+ node: function (node) {
115
114
  this.___parent.___appendChild(node);
116
115
  return this;
117
116
  },
118
117
 
119
- text: function(text, ownerComponent) {
118
+ text: function (text, ownerComponent) {
120
119
  var type = typeof text;
121
120
 
122
121
  if (type != "string") {
@@ -135,24 +134,20 @@ var proto = (AsyncVDOMBuilder.prototype = {
135
134
  return this;
136
135
  },
137
136
 
138
- comment: function(comment, ownerComponent) {
137
+ comment: function (comment, ownerComponent) {
139
138
  return this.node(new VComment(comment, ownerComponent));
140
139
  },
141
140
 
142
- html: function(html, ownerComponent) {
141
+ html: function (html, ownerComponent) {
143
142
  if (html != null) {
144
- var vdomNode = virtualizeHTML(
145
- html,
146
- this.___document || document,
147
- ownerComponent
148
- );
143
+ var vdomNode = virtualizeHTML(html, ownerComponent);
149
144
  this.node(vdomNode);
150
145
  }
151
146
 
152
147
  return this;
153
148
  },
154
149
 
155
- beginElement: function(
150
+ beginElement: function (
156
151
  tagName,
157
152
  attrs,
158
153
  key,
@@ -174,7 +169,7 @@ var proto = (AsyncVDOMBuilder.prototype = {
174
169
  return this;
175
170
  },
176
171
 
177
- ___beginElementDynamic: function(tagName, attrs, key, componentDef, props) {
172
+ ___beginElementDynamic: function (tagName, attrs, key, componentDef, props) {
178
173
  return this.beginElement(
179
174
  tagName,
180
175
  attrsHelper(attrs),
@@ -186,23 +181,23 @@ var proto = (AsyncVDOMBuilder.prototype = {
186
181
  );
187
182
  },
188
183
 
189
- bf: function(key, component, preserve) {
184
+ bf: function (key, component, preserve) {
190
185
  var fragment = new VFragment(key, component, preserve);
191
186
  this.___beginNode(fragment, null, true);
192
187
  return this;
193
188
  },
194
189
 
195
- ef: function() {
190
+ ef: function () {
196
191
  this.endElement();
197
192
  },
198
193
 
199
- endElement: function() {
194
+ endElement: function () {
200
195
  var stack = this.___stack;
201
196
  stack.pop();
202
197
  this.___parent = stack[stack.length - 1];
203
198
  },
204
199
 
205
- end: function() {
200
+ end: function () {
206
201
  this.___parent = undefined;
207
202
 
208
203
  var remaining = --this.___remaining;
@@ -221,7 +216,7 @@ var proto = (AsyncVDOMBuilder.prototype = {
221
216
  return this;
222
217
  },
223
218
 
224
- ___handleChildDone: function() {
219
+ ___handleChildDone: function () {
225
220
  var remaining = --this.___remaining;
226
221
 
227
222
  if (remaining === 0) {
@@ -236,13 +231,13 @@ var proto = (AsyncVDOMBuilder.prototype = {
236
231
  }
237
232
  },
238
233
 
239
- ___doFinish: function() {
234
+ ___doFinish: function () {
240
235
  var state = this.___state;
241
236
  state.___finished = true;
242
237
  state.___events.emit(EVENT_FINISH, this.___getResult());
243
238
  },
244
239
 
245
- ___emitLast: function() {
240
+ ___emitLast: function () {
246
241
  var lastArray = this._last;
247
242
 
248
243
  var i = 0;
@@ -262,7 +257,7 @@ var proto = (AsyncVDOMBuilder.prototype = {
262
257
  next();
263
258
  },
264
259
 
265
- error: function(e) {
260
+ error: function (e) {
266
261
  try {
267
262
  this.emit("error", e);
268
263
  } finally {
@@ -276,7 +271,7 @@ var proto = (AsyncVDOMBuilder.prototype = {
276
271
  return this;
277
272
  },
278
273
 
279
- beginAsync: function(options) {
274
+ beginAsync: function (options) {
280
275
  if (this.___sync) {
281
276
  throw Error(
282
277
  "Tried to render async while in sync mode. Note: Client side await is not currently supported in re-renders (Issue: #942)."
@@ -304,11 +299,11 @@ var proto = (AsyncVDOMBuilder.prototype = {
304
299
  return asyncOut;
305
300
  },
306
301
 
307
- createOut: function() {
302
+ createOut: function () {
308
303
  return new AsyncVDOMBuilder(this.global);
309
304
  },
310
305
 
311
- flush: function() {
306
+ flush: function () {
312
307
  var events = this.___state.___events;
313
308
 
314
309
  if (events.listenerCount(EVENT_UPDATE)) {
@@ -316,15 +311,15 @@ var proto = (AsyncVDOMBuilder.prototype = {
316
311
  }
317
312
  },
318
313
 
319
- ___getOutput: function() {
314
+ ___getOutput: function () {
320
315
  return this.___state.___tree;
321
316
  },
322
317
 
323
- ___getResult: function() {
318
+ ___getResult: function () {
324
319
  return this.___result || (this.___result = new RenderResult(this));
325
320
  },
326
321
 
327
- on: function(event, callback) {
322
+ on: function (event, callback) {
328
323
  var state = this.___state;
329
324
 
330
325
  if (event === EVENT_FINISH && state.___finished) {
@@ -338,7 +333,7 @@ var proto = (AsyncVDOMBuilder.prototype = {
338
333
  return this;
339
334
  },
340
335
 
341
- once: function(event, callback) {
336
+ once: function (event, callback) {
342
337
  var state = this.___state;
343
338
 
344
339
  if (event === EVENT_FINISH && state.___finished) {
@@ -352,7 +347,7 @@ var proto = (AsyncVDOMBuilder.prototype = {
352
347
  return this;
353
348
  },
354
349
 
355
- emit: function(type, arg) {
350
+ emit: function (type, arg) {
356
351
  var events = this.___state.___events;
357
352
  switch (arguments.length) {
358
353
  case 1:
@@ -368,21 +363,21 @@ var proto = (AsyncVDOMBuilder.prototype = {
368
363
  return this;
369
364
  },
370
365
 
371
- removeListener: function() {
366
+ removeListener: function () {
372
367
  var events = this.___state.___events;
373
368
  events.removeListener.apply(events, arguments);
374
369
  return this;
375
370
  },
376
371
 
377
- sync: function() {
372
+ sync: function () {
378
373
  this.___sync = true;
379
374
  },
380
375
 
381
- isSync: function() {
376
+ isSync: function () {
382
377
  return this.___sync;
383
378
  },
384
379
 
385
- onLast: function(callback) {
380
+ onLast: function (callback) {
386
381
  var lastArray = this._last;
387
382
 
388
383
  if (lastArray === undefined) {
@@ -394,20 +389,20 @@ var proto = (AsyncVDOMBuilder.prototype = {
394
389
  return this;
395
390
  },
396
391
 
397
- ___getNode: function(doc) {
392
+ ___getNode: function (host) {
398
393
  var node = this.___vnode;
399
394
  if (!node) {
400
395
  var vdomTree = this.___getOutput();
401
- // Create the root document fragment node
402
- doc = doc || this.___document || document;
403
- this.___vnode = node = vdomTree.___actualize(doc, null);
404
- morphdom(node, vdomTree, doc, this.___components);
396
+
397
+ if (!host) host = this.___host;
398
+ this.___vnode = node = vdomTree.___actualize(host, null);
399
+ morphdom(node, vdomTree, host, this.___components);
405
400
  }
406
401
  return node;
407
402
  },
408
403
 
409
- toString: function(doc) {
410
- var docFragment = this.___getNode(doc);
404
+ toString: function (host) {
405
+ var docFragment = this.___getNode(host);
411
406
  var html = "";
412
407
 
413
408
  var child = docFragment.firstChild;
@@ -427,10 +422,10 @@ var proto = (AsyncVDOMBuilder.prototype = {
427
422
  return html;
428
423
  },
429
424
 
430
- then: function(fn, fnErr) {
425
+ then: function (fn, fnErr) {
431
426
  var out = this;
432
- var promise = new Promise(function(resolve, reject) {
433
- out.on("error", reject).on(EVENT_FINISH, function(result) {
427
+ var promise = new Promise(function (resolve, reject) {
428
+ out.on("error", reject).on(EVENT_FINISH, function (result) {
434
429
  resolve(result);
435
430
  });
436
431
  });
@@ -438,13 +433,13 @@ var proto = (AsyncVDOMBuilder.prototype = {
438
433
  return Promise.resolve(promise).then(fn, fnErr);
439
434
  },
440
435
 
441
- catch: function(fnErr) {
436
+ catch: function (fnErr) {
442
437
  return this.then(undefined, fnErr);
443
438
  },
444
439
 
445
440
  isVDOM: true,
446
441
 
447
- c: function(componentDef, key, customEvents) {
442
+ c: function (componentDef, key, customEvents) {
448
443
  this.___assignedComponentDef = componentDef;
449
444
  this.___assignedKey = key;
450
445
  this.___assignedCustomEvents = customEvents;
@@ -9,12 +9,12 @@ function VComment(value, ownerComponent) {
9
9
  VComment.prototype = {
10
10
  ___nodeType: 8,
11
11
 
12
- ___actualize: function(doc) {
12
+ ___actualize: function (host) {
13
13
  var nodeValue = this.___nodeValue;
14
- return doc.createComment(nodeValue);
14
+ return (host.ownerDocument || host).createComment(nodeValue);
15
15
  },
16
16
 
17
- ___cloneNode: function() {
17
+ ___cloneNode: function () {
18
18
  return new VComment(this.___nodeValue);
19
19
  }
20
20
  };
@@ -18,12 +18,12 @@ VDocumentFragment.prototype = {
18
18
 
19
19
  ___DocumentFragment: true,
20
20
 
21
- ___cloneNode: function() {
21
+ ___cloneNode: function () {
22
22
  return new VDocumentFragmentClone(this);
23
23
  },
24
24
 
25
- ___actualize: function(doc) {
26
- return doc.createDocumentFragment();
25
+ ___actualize: function (host) {
26
+ return (host.ownerDocument || host).createDocumentFragment();
27
27
  }
28
28
  };
29
29