marko 5.39.4 → 5.39.5

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.
@@ -6,14 +6,12 @@ var FLAG_WILL_RERENDER_IN_BROWSER = 1;
6
6
  var kAssets = Symbol();
7
7
  var kBlockIndex = Symbol();
8
8
  var kDeferIndex = Symbol();
9
- var kOriginal = Symbol();
10
9
  var assetFlush;
11
10
 
12
11
  exports.withPageAssets = function withPageAssets(typeId, template, runtime) {
13
12
  assetFlush = runtime;
14
- var render = template[kOriginal] || (template[kOriginal] = template._);
15
13
  var flushBeforeInput = { renderBody: flush };
16
- template._ = function (input, out) {
14
+ return createFacade(template, function (input, out) {
17
15
  var hasAssets = !!out.global[kAssets];
18
16
  var key = out.ad_;
19
17
  var def = out.ac_;
@@ -32,15 +30,12 @@ exports.withPageAssets = function withPageAssets(typeId, template, runtime) {
32
30
  flushHereAndAfter(flushBeforeInput, out);
33
31
  }
34
32
 
35
- render(input, out);
36
- };
37
- return template;
33
+ template._(input, out);
34
+ });
38
35
  };
39
36
 
40
37
  exports.withLoadAssets = function withLoadAssets(typeId, template, triggers) {
41
- if (template[kOriginal]) return template;
42
- var render = template[kOriginal] = template._;
43
- template._ = function (input, out) {
38
+ return createFacade(template, function (input, out) {
44
39
  var key = out.ad_;
45
40
  var def = out.ac_;
46
41
  addAsset(out.global, typeId, triggers);
@@ -50,16 +45,23 @@ exports.withLoadAssets = function withLoadAssets(typeId, template, triggers) {
50
45
  flush(out);
51
46
  out.ef();
52
47
  out.bf(key, def.s_, true);
53
- render(input, out);
48
+ template._(input, out);
54
49
  out.ef();
55
50
  } else {
56
51
  flush(out);
57
- render(input, out);
52
+ template._(input, out);
58
53
  }
59
- };
60
- return template;
54
+ });
61
55
  };
62
56
 
57
+ function createFacade(template, render) {
58
+ // Under hot reload the template's `_` is an accessor, which a normal
59
+ // assignment through the facade's prototype chain would invoke (storing
60
+ // the wrapped render as the template's own render fn), so the facade's
61
+ // render is defined as an own property instead.
62
+ return Object.create(template, { _: { value: render } });
63
+ }
64
+
63
65
  exports.flushHead = function flushHead(out) {
64
66
  if (out.global[kAssets]) {
65
67
  flush(out);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "5.39.4",
3
+ "version": "5.39.5",
4
4
  "description": "UI Components + streaming, async, high performance, HTML templating for Node.js and the browser.",
5
5
  "keywords": [
6
6
  "front-end",
@@ -6,14 +6,12 @@ var FLAG_WILL_RERENDER_IN_BROWSER = 1;
6
6
  var kAssets = Symbol();
7
7
  var kBlockIndex = Symbol();
8
8
  var kDeferIndex = Symbol();
9
- var kOriginal = Symbol();
10
9
  var assetFlush;
11
10
 
12
11
  exports.withPageAssets = function withPageAssets(typeId, template, runtime) {
13
12
  assetFlush = runtime;
14
- var render = template[kOriginal] || (template[kOriginal] = template._);
15
13
  var flushBeforeInput = { renderBody: flush };
16
- template._ = function (input, out) {
14
+ return createFacade(template, function (input, out) {
17
15
  var hasAssets = !!out.global[kAssets];
18
16
  var key = out.___assignedKey;
19
17
  var def = out.___assignedComponentDef;
@@ -32,15 +30,12 @@ exports.withPageAssets = function withPageAssets(typeId, template, runtime) {
32
30
  flushHereAndAfter(flushBeforeInput, out);
33
31
  }
34
32
 
35
- render(input, out);
36
- };
37
- return template;
33
+ template._(input, out);
34
+ });
38
35
  };
39
36
 
40
37
  exports.withLoadAssets = function withLoadAssets(typeId, template, triggers) {
41
- if (template[kOriginal]) return template;
42
- var render = (template[kOriginal] = template._);
43
- template._ = function (input, out) {
38
+ return createFacade(template, function (input, out) {
44
39
  var key = out.___assignedKey;
45
40
  var def = out.___assignedComponentDef;
46
41
  addAsset(out.global, typeId, triggers);
@@ -50,16 +45,23 @@ exports.withLoadAssets = function withLoadAssets(typeId, template, triggers) {
50
45
  flush(out);
51
46
  out.ef();
52
47
  out.bf(key, def.___component, true);
53
- render(input, out);
48
+ template._(input, out);
54
49
  out.ef();
55
50
  } else {
56
51
  flush(out);
57
- render(input, out);
52
+ template._(input, out);
58
53
  }
59
- };
60
- return template;
54
+ });
61
55
  };
62
56
 
57
+ function createFacade(template, render) {
58
+ // Under hot reload the template's `_` is an accessor, which a normal
59
+ // assignment through the facade's prototype chain would invoke (storing
60
+ // the wrapped render as the template's own render fn), so the facade's
61
+ // render is defined as an own property instead.
62
+ return Object.create(template, { _: { value: render } });
63
+ }
64
+
63
65
  exports.flushHead = function flushHead(out) {
64
66
  if (out.global[kAssets]) {
65
67
  flush(out);