marko 5.32.7 → 5.32.9

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.
@@ -115,8 +115,14 @@ module.exports = function awaitTag(input, out) {
115
115
  nextId: 0
116
116
  });
117
117
 
118
- var id = awaitInfo.id = input.name || clientReorderContext.nextId++;
119
- var placeholderIdAttrValue = "afph" + id;
118
+ /** SHOULD MATCH THE reorder-renderer.js IMPLEMENTATION */
119
+ var reorderFunctionId =
120
+ out.global.runtimeId !== "M" ? "af" + out.global.runtimeId : "af";
121
+
122
+ var id = awaitInfo.id =
123
+ input.name ||
124
+ (out.global.componentIdPrefix || 0) + clientReorderContext.nextId++;
125
+ var placeholderIdAttrValue = reorderFunctionId + "ph" + id;
120
126
 
121
127
  if (placeholderRenderer) {
122
128
  out.write('<span id="' + placeholderIdAttrValue + '">');
@@ -24,6 +24,10 @@ module.exports = function (input, out) {
24
24
  out.flush();
25
25
  }
26
26
 
27
+ /** SHOULD MATCH THE renderer.js IMPLEMENTATION */
28
+ var reorderFunctionId =
29
+ out.global.runtimeId !== "M" ? "af" + out.global.runtimeId : "af";
30
+
27
31
  var asyncOut = out.beginAsync({
28
32
  last: true,
29
33
  timeout: -1,
@@ -52,7 +56,7 @@ module.exports = function (input, out) {
52
56
  if (!global._afRuntime) {
53
57
  // Minified version of ./client-reorder-runtime.js
54
58
  asyncOut.script(
55
- `function $af(d,a,e,l,g,h,k,b,f,c){c=$af;if(a&&!c[a])(c[a+="$"]||(c[a]=[])).push(d);else{e=document;l=e.getElementById("af"+d);g=e.getElementById("afph"+d);h=e.createDocumentFragment();k=l.childNodes;b=0;for(f=k.length;b<f;b++)h.appendChild(k.item(0));g&&g.parentNode.replaceChild(h,g);c[d]=1;if(a=c[d+"$"])for(b=0,f=a.length;b<f;b++)c(a[b])}}`
59
+ `function $${reorderFunctionId}(d,a,e,l,g,h,k,b,f,c){c=$${reorderFunctionId};if(a&&!c[a])(c[a+="$"]||(c[a]=[])).push(d);else{e=document;l=e.getElementById("${reorderFunctionId}"+d);g=e.getElementById("${reorderFunctionId}ph"+d);h=e.createDocumentFragment();k=l.childNodes;b=0;for(f=k.length;b<f;b++)h.appendChild(k.item(0));g&&g.parentNode.replaceChild(h,g);c[d]=1;if(a=c[d+"$"])for(b=0,f=a.length;b<f;b++)c(a[b])}}`
56
60
  );
57
61
  global._afRuntime = true;
58
62
  }
@@ -62,11 +66,11 @@ module.exports = function (input, out) {
62
66
  '<style nonce="' +
63
67
  escapeDoubleQuotes(global.cspNonce) +
64
68
  '">' +
65
- "#af" +
69
+ `#${reorderFunctionId}` +
66
70
  awaitInfo.id +
67
71
  "{display:none;}" +
68
72
  "</style>" +
69
- '<div id="af' +
73
+ `<div id="${reorderFunctionId}` +
70
74
  awaitInfo.id +
71
75
  '">' +
72
76
  result.toString() +
@@ -74,7 +78,7 @@ module.exports = function (input, out) {
74
78
  );
75
79
  } else {
76
80
  asyncOut.write(
77
- '<div id="af' +
81
+ `<div id="${reorderFunctionId}` +
78
82
  awaitInfo.id +
79
83
  '" style="display:none">' +
80
84
  result.toString() +
@@ -83,7 +87,7 @@ module.exports = function (input, out) {
83
87
  }
84
88
 
85
89
  asyncOut.script(
86
- "$af(" + (
90
+ `$${reorderFunctionId}(` + (
87
91
  typeof awaitInfo.id === "number" ?
88
92
  awaitInfo.id :
89
93
  '"' + awaitInfo.id + '"') + (
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ var VElement = require("../vdom").br_;
4
+ var i = 0;
5
+
6
+ module.exports = function (tagName, attrs, childCount) {
7
+ return new ConstVElement(tagName, attrs, childCount);
8
+ };
9
+
10
+ function ConstVElement(tagName, attrs, childCount) {
11
+ VElement.call(this, tagName, attrs, null, null, childCount, null, { i: i++ });
12
+ }
13
+
14
+ ConstVElement.prototype = Object.create(VElement.prototype);
15
+ ConstVElement.prototype.e = function (tagName, attrs, childCount) {
16
+ var child = this.bI_(
17
+ new ConstVElement(tagName, attrs, childCount)
18
+ );
19
+
20
+ if (childCount === 0) {
21
+ return this.ca_();
22
+ } else {
23
+ return child;
24
+ }
25
+ };
@@ -281,13 +281,26 @@ function morphdom(fromNode, toNode, host, componentsContext) {
281
281
  if (!curToNodeChild.aa_) {
282
282
  // We just skip over the fromNode if it is preserved
283
283
 
284
- if (compareNodeNames(curToNodeChild, curVFromNodeChild)) {
285
- morphEl(
286
- curFromNodeChild,
287
- curVFromNodeChild,
288
- curToNodeChild,
289
- parentComponent
290
- );
284
+ if (
285
+ curVFromNodeChild &&
286
+ curToNodeType === curVFromNodeChild.bS_ && (
287
+ curToNodeType !== ELEMENT_NODE ||
288
+ compareNodeNames(curToNodeChild, curVFromNodeChild)))
289
+ {
290
+ if (curToNodeType === ELEMENT_NODE) {
291
+ morphEl(
292
+ curFromNodeChild,
293
+ curVFromNodeChild,
294
+ curToNodeChild,
295
+ parentComponent
296
+ );
297
+ } else {
298
+ morphChildren(
299
+ curFromNodeChild,
300
+ curToNodeChild,
301
+ parentComponent
302
+ );
303
+ }
291
304
  } else {
292
305
  // Remove the old node
293
306
  detachNode(curFromNodeChild, fromNode, ownerComponent);
@@ -404,7 +417,12 @@ function morphdom(fromNode, toNode, host, componentsContext) {
404
417
  if (!curToNodeChild.aa_) {
405
418
  curVFromNodeChild = vElementByDOMNode.get(matchingFromEl);
406
419
 
407
- if (compareNodeNames(curVFromNodeChild, curToNodeChild)) {
420
+ if (
421
+ curVFromNodeChild &&
422
+ curToNodeType === curVFromNodeChild.bS_ && (
423
+ curToNodeType !== ELEMENT_NODE ||
424
+ compareNodeNames(curVFromNodeChild, curToNodeChild)))
425
+ {
408
426
  if (fromNextSibling === matchingFromEl) {
409
427
  // Single element removal:
410
428
  // A <-> A
@@ -455,12 +473,20 @@ function morphdom(fromNode, toNode, host, componentsContext) {
455
473
  }
456
474
  }
457
475
 
458
- morphEl(
459
- matchingFromEl,
460
- curVFromNodeChild,
461
- curToNodeChild,
462
- parentComponent
463
- );
476
+ if (curToNodeType === ELEMENT_NODE) {
477
+ morphEl(
478
+ matchingFromEl,
479
+ curVFromNodeChild,
480
+ curToNodeChild,
481
+ parentComponent
482
+ );
483
+ } else {
484
+ morphChildren(
485
+ matchingFromEl,
486
+ curToNodeChild,
487
+ parentComponent
488
+ );
489
+ }
464
490
  } else {
465
491
  insertVirtualNodeBefore(
466
492
  curToNodeChild,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "5.32.7",
3
+ "version": "5.32.9",
4
4
  "description": "UI Components + streaming, async, high performance, HTML templating for Node.js and the browser.",
5
5
  "keywords": [
6
6
  "front-end",
@@ -65,7 +65,7 @@
65
65
  },
66
66
  "dependencies": {
67
67
  "@marko/compiler": "^5.34.6",
68
- "@marko/translator-default": "^5.31.13",
68
+ "@marko/translator-default": "^5.31.14",
69
69
  "app-module-path": "^2.2.0",
70
70
  "argly": "^1.2.0",
71
71
  "browser-refresh-client": "1.1.4",
@@ -115,8 +115,14 @@ module.exports = function awaitTag(input, out) {
115
115
  nextId: 0,
116
116
  });
117
117
 
118
- var id = (awaitInfo.id = input.name || clientReorderContext.nextId++);
119
- var placeholderIdAttrValue = "afph" + id;
118
+ /** SHOULD MATCH THE reorder-renderer.js IMPLEMENTATION */
119
+ var reorderFunctionId =
120
+ out.global.runtimeId !== "M" ? "af" + out.global.runtimeId : "af";
121
+
122
+ var id = (awaitInfo.id =
123
+ input.name ||
124
+ (out.global.componentIdPrefix || 0) + clientReorderContext.nextId++);
125
+ var placeholderIdAttrValue = reorderFunctionId + "ph" + id;
120
126
 
121
127
  if (placeholderRenderer) {
122
128
  out.write('<span id="' + placeholderIdAttrValue + '">');
@@ -24,6 +24,10 @@ module.exports = function (input, out) {
24
24
  out.flush();
25
25
  }
26
26
 
27
+ /** SHOULD MATCH THE renderer.js IMPLEMENTATION */
28
+ var reorderFunctionId =
29
+ out.global.runtimeId !== "M" ? "af" + out.global.runtimeId : "af";
30
+
27
31
  var asyncOut = out.beginAsync({
28
32
  last: true,
29
33
  timeout: -1,
@@ -52,7 +56,7 @@ module.exports = function (input, out) {
52
56
  if (!global._afRuntime) {
53
57
  // Minified version of ./client-reorder-runtime.js
54
58
  asyncOut.script(
55
- `function $af(d,a,e,l,g,h,k,b,f,c){c=$af;if(a&&!c[a])(c[a+="$"]||(c[a]=[])).push(d);else{e=document;l=e.getElementById("af"+d);g=e.getElementById("afph"+d);h=e.createDocumentFragment();k=l.childNodes;b=0;for(f=k.length;b<f;b++)h.appendChild(k.item(0));g&&g.parentNode.replaceChild(h,g);c[d]=1;if(a=c[d+"$"])for(b=0,f=a.length;b<f;b++)c(a[b])}}`,
59
+ `function $${reorderFunctionId}(d,a,e,l,g,h,k,b,f,c){c=$${reorderFunctionId};if(a&&!c[a])(c[a+="$"]||(c[a]=[])).push(d);else{e=document;l=e.getElementById("${reorderFunctionId}"+d);g=e.getElementById("${reorderFunctionId}ph"+d);h=e.createDocumentFragment();k=l.childNodes;b=0;for(f=k.length;b<f;b++)h.appendChild(k.item(0));g&&g.parentNode.replaceChild(h,g);c[d]=1;if(a=c[d+"$"])for(b=0,f=a.length;b<f;b++)c(a[b])}}`,
56
60
  );
57
61
  global._afRuntime = true;
58
62
  }
@@ -62,11 +66,11 @@ module.exports = function (input, out) {
62
66
  '<style nonce="' +
63
67
  escapeDoubleQuotes(global.cspNonce) +
64
68
  '">' +
65
- "#af" +
69
+ `#${reorderFunctionId}` +
66
70
  awaitInfo.id +
67
71
  "{display:none;}" +
68
72
  "</style>" +
69
- '<div id="af' +
73
+ `<div id="${reorderFunctionId}` +
70
74
  awaitInfo.id +
71
75
  '">' +
72
76
  result.toString() +
@@ -74,7 +78,7 @@ module.exports = function (input, out) {
74
78
  );
75
79
  } else {
76
80
  asyncOut.write(
77
- '<div id="af' +
81
+ `<div id="${reorderFunctionId}` +
78
82
  awaitInfo.id +
79
83
  '" style="display:none">' +
80
84
  result.toString() +
@@ -83,7 +87,7 @@ module.exports = function (input, out) {
83
87
  }
84
88
 
85
89
  asyncOut.script(
86
- "$af(" +
90
+ `$${reorderFunctionId}(` +
87
91
  (typeof awaitInfo.id === "number"
88
92
  ? awaitInfo.id
89
93
  : '"' + awaitInfo.id + '"') +
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ var VElement = require("../vdom").___VElement;
4
+ var i = 0;
5
+
6
+ module.exports = function (tagName, attrs, childCount) {
7
+ return new ConstVElement(tagName, attrs, childCount);
8
+ };
9
+
10
+ function ConstVElement(tagName, attrs, childCount) {
11
+ VElement.call(this, tagName, attrs, null, null, childCount, null, { i: i++ });
12
+ }
13
+
14
+ ConstVElement.prototype = Object.create(VElement.prototype);
15
+ ConstVElement.prototype.e = function (tagName, attrs, childCount) {
16
+ var child = this.___appendChild(
17
+ new ConstVElement(tagName, attrs, childCount),
18
+ );
19
+
20
+ if (childCount === 0) {
21
+ return this.___finishChild();
22
+ } else {
23
+ return child;
24
+ }
25
+ };
@@ -281,13 +281,26 @@ function morphdom(fromNode, toNode, host, componentsContext) {
281
281
  if (!curToNodeChild.___preserve) {
282
282
  // We just skip over the fromNode if it is preserved
283
283
 
284
- if (compareNodeNames(curToNodeChild, curVFromNodeChild)) {
285
- morphEl(
286
- curFromNodeChild,
287
- curVFromNodeChild,
288
- curToNodeChild,
289
- parentComponent,
290
- );
284
+ if (
285
+ curVFromNodeChild &&
286
+ curToNodeType === curVFromNodeChild.___nodeType &&
287
+ (curToNodeType !== ELEMENT_NODE ||
288
+ compareNodeNames(curToNodeChild, curVFromNodeChild))
289
+ ) {
290
+ if (curToNodeType === ELEMENT_NODE) {
291
+ morphEl(
292
+ curFromNodeChild,
293
+ curVFromNodeChild,
294
+ curToNodeChild,
295
+ parentComponent,
296
+ );
297
+ } else {
298
+ morphChildren(
299
+ curFromNodeChild,
300
+ curToNodeChild,
301
+ parentComponent,
302
+ );
303
+ }
291
304
  } else {
292
305
  // Remove the old node
293
306
  detachNode(curFromNodeChild, fromNode, ownerComponent);
@@ -404,7 +417,12 @@ function morphdom(fromNode, toNode, host, componentsContext) {
404
417
  if (!curToNodeChild.___preserve) {
405
418
  curVFromNodeChild = vElementByDOMNode.get(matchingFromEl);
406
419
 
407
- if (compareNodeNames(curVFromNodeChild, curToNodeChild)) {
420
+ if (
421
+ curVFromNodeChild &&
422
+ curToNodeType === curVFromNodeChild.___nodeType &&
423
+ (curToNodeType !== ELEMENT_NODE ||
424
+ compareNodeNames(curVFromNodeChild, curToNodeChild))
425
+ ) {
408
426
  if (fromNextSibling === matchingFromEl) {
409
427
  // Single element removal:
410
428
  // A <-> A
@@ -455,12 +473,20 @@ function morphdom(fromNode, toNode, host, componentsContext) {
455
473
  }
456
474
  }
457
475
 
458
- morphEl(
459
- matchingFromEl,
460
- curVFromNodeChild,
461
- curToNodeChild,
462
- parentComponent,
463
- );
476
+ if (curToNodeType === ELEMENT_NODE) {
477
+ morphEl(
478
+ matchingFromEl,
479
+ curVFromNodeChild,
480
+ curToNodeChild,
481
+ parentComponent,
482
+ );
483
+ } else {
484
+ morphChildren(
485
+ matchingFromEl,
486
+ curToNodeChild,
487
+ parentComponent,
488
+ );
489
+ }
464
490
  } else {
465
491
  insertVirtualNodeBefore(
466
492
  curToNodeChild,
@@ -1,8 +0,0 @@
1
- "use strict";
2
-
3
- module.exports = function (id) {
4
- var i = 0;
5
- return function () {
6
- return id + i++;
7
- };
8
- };
@@ -1,15 +0,0 @@
1
- "use strict";
2
-
3
- var VElement = require("../vdom").br_;
4
-
5
- module.exports = function (
6
- tagName,
7
- attrs,
8
- key,
9
- component,
10
- childCount,
11
- flags,
12
- props)
13
- {
14
- return new VElement(tagName, attrs, key, component, childCount, flags, props);
15
- };
@@ -1,7 +0,0 @@
1
- "use strict";
2
-
3
- var VText = require("../vdom").bt_;
4
-
5
- module.exports = function (value) {
6
- return new VText(value);
7
- };
@@ -1,8 +0,0 @@
1
- "use strict";
2
-
3
- module.exports = function (id) {
4
- var i = 0;
5
- return function () {
6
- return id + i++;
7
- };
8
- };
@@ -1,15 +0,0 @@
1
- "use strict";
2
-
3
- var VElement = require("../vdom").___VElement;
4
-
5
- module.exports = function (
6
- tagName,
7
- attrs,
8
- key,
9
- component,
10
- childCount,
11
- flags,
12
- props,
13
- ) {
14
- return new VElement(tagName, attrs, key, component, childCount, flags, props);
15
- };
@@ -1,7 +0,0 @@
1
- "use strict";
2
-
3
- var VText = require("../vdom").___VText;
4
-
5
- module.exports = function (value) {
6
- return new VText(value);
7
- };