marko 5.33.3 → 5.33.5
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/runtime/helpers/tags-compat/dom-debug.js +1 -0
- package/dist/runtime/helpers/tags-compat/dom-debug.mjs +3 -0
- package/dist/runtime/helpers/tags-compat/dom.js +1 -0
- package/dist/runtime/helpers/tags-compat/dom.mjs +3 -0
- package/dist/runtime/helpers/tags-compat/html-debug.js +3 -0
- package/dist/runtime/helpers/tags-compat/html-debug.mjs +3 -0
- package/dist/runtime/helpers/tags-compat/html.js +1 -0
- package/dist/runtime/helpers/tags-compat/html.mjs +3 -0
- package/dist/runtime/helpers/tags-compat/runtime-dom.js +231 -0
- package/dist/runtime/helpers/tags-compat/runtime-html.js +171 -0
- package/dist/runtime/html/AsyncStream.js +12 -12
- package/dist/runtime/html/helpers/_dynamic-attr.js +2 -2
- package/dist/runtime/html/helpers/attr.js +3 -3
- package/dist/runtime/html/helpers/data-marko.js +1 -1
- package/dist/runtime/html/helpers/escape-quotes.js +1 -1
- package/dist/runtime/html/helpers/escape-xml.js +1 -1
- package/dist/runtime/renderable.js +3 -3
- package/dist/runtime/vdom/AsyncVDOMBuilder.js +67 -67
- package/dist/runtime/vdom/VComponent.js +3 -3
- package/dist/runtime/vdom/VDocumentFragment.js +7 -7
- package/dist/runtime/vdom/VElement.js +35 -35
- package/dist/runtime/vdom/VFragment.js +5 -5
- package/dist/runtime/vdom/VNode.js +30 -30
- package/dist/runtime/vdom/VText.js +8 -8
- package/dist/runtime/vdom/helpers/const-element.js +3 -3
- package/dist/runtime/vdom/hot-reload.js +2 -2
- package/dist/runtime/vdom/morphdom/fragment.js +3 -3
- package/dist/runtime/vdom/morphdom/helpers.js +1 -1
- package/dist/runtime/vdom/morphdom/index.js +31 -31
- package/dist/runtime/vdom/vdom.js +14 -14
- package/package.json +4 -4
- package/src/runtime/helpers/tags-compat/dom-debug.js +1 -0
- package/src/runtime/helpers/tags-compat/dom-debug.mjs +3 -0
- package/src/runtime/helpers/tags-compat/dom.js +1 -0
- package/src/runtime/helpers/tags-compat/dom.mjs +3 -0
- package/src/runtime/helpers/tags-compat/html-debug.js +3 -0
- package/src/runtime/helpers/tags-compat/html-debug.mjs +3 -0
- package/src/runtime/helpers/tags-compat/html.js +1 -0
- package/src/runtime/helpers/tags-compat/html.mjs +3 -0
- package/src/runtime/helpers/tags-compat/runtime-dom.js +231 -0
- package/src/runtime/helpers/tags-compat/runtime-html.js +171 -0
- package/dist/runtime/helpers/tags-compat-dom.js +0 -276
- package/dist/runtime/helpers/tags-compat-html.js +0 -172
- package/src/runtime/helpers/tags-compat-dom.js +0 -276
- package/src/runtime/helpers/tags-compat-html.js +0 -172
@@ -2,21 +2,21 @@
|
|
2
2
|
var VNode = require("./VNode");
|
3
3
|
|
4
4
|
function VText(value, ownerComponent) {
|
5
|
-
this.
|
6
|
-
this.
|
5
|
+
this.bT_(-1 /* no children */, ownerComponent);
|
6
|
+
this.cm_ = value;
|
7
7
|
}
|
8
8
|
|
9
9
|
VText.prototype = {
|
10
|
-
|
10
|
+
cl_: true,
|
11
11
|
|
12
|
-
|
12
|
+
bV_: 3,
|
13
13
|
|
14
|
-
|
15
|
-
return (host.ownerDocument || host).createTextNode(this.
|
14
|
+
bl_: function (host) {
|
15
|
+
return (host.ownerDocument || host).createTextNode(this.cm_);
|
16
16
|
},
|
17
17
|
|
18
|
-
|
19
|
-
return new VText(this.
|
18
|
+
bN_: function () {
|
19
|
+
return new VText(this.cm_);
|
20
20
|
}
|
21
21
|
};
|
22
22
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var VElement = require("../vdom").
|
3
|
+
var VElement = require("../vdom").bv_;
|
4
4
|
var i = 0;
|
5
5
|
|
6
6
|
module.exports = function (tagName, attrs, childCount) {
|
@@ -13,12 +13,12 @@ function ConstVElement(tagName, attrs, childCount) {
|
|
13
13
|
|
14
14
|
ConstVElement.prototype = Object.create(VElement.prototype);
|
15
15
|
ConstVElement.prototype.e = function (tagName, attrs, childCount) {
|
16
|
-
var child = this.
|
16
|
+
var child = this.bM_(
|
17
17
|
new ConstVElement(tagName, attrs, childCount)
|
18
18
|
);
|
19
19
|
|
20
20
|
if (childCount === 0) {
|
21
|
-
return this.
|
21
|
+
return this.cd_();
|
22
22
|
} else {
|
23
23
|
return child;
|
24
24
|
}
|
@@ -44,7 +44,7 @@ exports.t = runtime.t = function (typeName) {
|
|
44
44
|
instance.P_(input, out);
|
45
45
|
};
|
46
46
|
|
47
|
-
instance.
|
47
|
+
instance.cn_ = true;
|
48
48
|
instance.am_();
|
49
49
|
instance._t_ = false;
|
50
50
|
|
@@ -78,7 +78,7 @@ registry._C_ = function (typeName, id) {
|
|
78
78
|
if (instances) {
|
79
79
|
instances.add(instance);
|
80
80
|
instance.once("destroy", function () {
|
81
|
-
if (!instance.
|
81
|
+
if (!instance.cn_) {
|
82
82
|
instances.delete(instance);
|
83
83
|
}
|
84
84
|
});
|
@@ -80,8 +80,8 @@ function createFragmentNode(startNode, nextNode, parentNode) {
|
|
80
80
|
|
81
81
|
function beginFragmentNode(startNode, parentNode) {
|
82
82
|
var fragment = createFragmentNode(startNode, null, parentNode);
|
83
|
-
fragment.
|
84
|
-
fragment.
|
83
|
+
fragment.co_ = function (nextNode) {
|
84
|
+
fragment.co_ = null;
|
85
85
|
insertBefore(
|
86
86
|
fragment.endNode,
|
87
87
|
nextNode,
|
@@ -92,4 +92,4 @@ function beginFragmentNode(startNode, parentNode) {
|
|
92
92
|
}
|
93
93
|
|
94
94
|
exports._h_ = createFragmentNode;
|
95
|
-
exports.
|
95
|
+
exports.cp_ = beginFragmentNode;
|
@@ -8,11 +8,11 @@ var normalizeComponentKey = componentsUtil._R_;
|
|
8
8
|
var domData = require("../../components/dom-data");
|
9
9
|
var eventDelegation = require("../../components/event-delegation");
|
10
10
|
var KeySequence = require("../../components/KeySequence");
|
11
|
-
var VElement = require("../vdom").
|
11
|
+
var VElement = require("../vdom").bv_;
|
12
12
|
var fragment = require("./fragment");
|
13
13
|
var helpers = require("./helpers");
|
14
|
-
var virtualizeElement = VElement.
|
15
|
-
var morphAttrs = VElement.
|
14
|
+
var virtualizeElement = VElement.cf_;
|
15
|
+
var morphAttrs = VElement.cg_;
|
16
16
|
var keysByDOMNode = domData._G_;
|
17
17
|
var componentByDOMNode = domData._l_;
|
18
18
|
var vElementByDOMNode = domData._H_;
|
@@ -20,11 +20,11 @@ var detachedByDOMNode = domData.aT_;
|
|
20
20
|
|
21
21
|
var insertBefore = helpers.bc_;
|
22
22
|
var insertAfter = helpers.bd_;
|
23
|
-
var nextSibling = helpers.
|
23
|
+
var nextSibling = helpers.ck_;
|
24
24
|
var firstChild = helpers.ay_;
|
25
25
|
var removeChild = helpers.be_;
|
26
26
|
var createFragmentNode = fragment._h_;
|
27
|
-
var beginFragmentNode = fragment.
|
27
|
+
var beginFragmentNode = fragment.cp_;
|
28
28
|
|
29
29
|
var ELEMENT_NODE = 1;
|
30
30
|
var TEXT_NODE = 3;
|
@@ -42,7 +42,7 @@ function isAutoKey(key) {
|
|
42
42
|
}
|
43
43
|
|
44
44
|
function compareNodeNames(fromEl, toEl) {
|
45
|
-
return fromEl.
|
45
|
+
return fromEl.ca_ === toEl.ca_;
|
46
46
|
}
|
47
47
|
|
48
48
|
function caseInsensitiveCompare(a, b) {
|
@@ -73,12 +73,12 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
73
73
|
ownerComponent,
|
74
74
|
parentComponent)
|
75
75
|
{
|
76
|
-
var realNode = vNode.
|
76
|
+
var realNode = vNode.bl_(host, parentEl.namespaceURI);
|
77
77
|
insertBefore(realNode, referenceEl, parentEl);
|
78
78
|
|
79
79
|
if (
|
80
|
-
vNode.
|
81
|
-
vNode.
|
80
|
+
vNode.bV_ === ELEMENT_NODE ||
|
81
|
+
vNode.bV_ === FRAGMENT_NODE)
|
82
82
|
{
|
83
83
|
if (key) {
|
84
84
|
keysByDOMNode.set(realNode, key);
|
@@ -87,7 +87,7 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
87
87
|
realNode;
|
88
88
|
}
|
89
89
|
|
90
|
-
if (vNode.
|
90
|
+
if (vNode.ca_ !== "textarea") {
|
91
91
|
morphChildren(realNode, vNode, parentComponent);
|
92
92
|
}
|
93
93
|
|
@@ -161,9 +161,9 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
161
161
|
var fromComponent;
|
162
162
|
|
163
163
|
outer: while (curToNodeChild) {
|
164
|
-
toNextSibling = curToNodeChild.
|
165
|
-
curToNodeType = curToNodeChild.
|
166
|
-
curToNodeKey = curToNodeChild.
|
164
|
+
toNextSibling = curToNodeChild.ck_;
|
165
|
+
curToNodeType = curToNodeChild.bV_;
|
166
|
+
curToNodeKey = curToNodeChild.bU_;
|
167
167
|
|
168
168
|
// Skip <!doctype>
|
169
169
|
if (curFromNodeChild && curFromNodeChild.nodeType === DOCTYPE_NODE) {
|
@@ -282,7 +282,7 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
282
282
|
|
283
283
|
if (
|
284
284
|
curVFromNodeChild &&
|
285
|
-
curToNodeType === curVFromNodeChild.
|
285
|
+
curToNodeType === curVFromNodeChild.bV_ && (
|
286
286
|
curToNodeType !== ELEMENT_NODE ||
|
287
287
|
compareNodeNames(curToNodeChild, curVFromNodeChild)))
|
288
288
|
{
|
@@ -327,11 +327,11 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
327
327
|
curToNodeChild.aa_ ||
|
328
328
|
caseInsensitiveCompare(
|
329
329
|
curFromNodeChild.nodeName,
|
330
|
-
curToNodeChild.
|
330
|
+
curToNodeChild.ca_ || ""
|
331
331
|
)))
|
332
332
|
{
|
333
333
|
curVFromNodeChild = virtualizeElement(curFromNodeChild);
|
334
|
-
curVFromNodeChild.
|
334
|
+
curVFromNodeChild.ca_ = curToNodeChild.ca_;
|
335
335
|
keysByDOMNode.set(curFromNodeChild, curToNodeKey);
|
336
336
|
referenceComponent.J_[curToNodeKey] =
|
337
337
|
curFromNodeChild;
|
@@ -351,7 +351,7 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
351
351
|
curFromNodeChild = fromNextSibling;
|
352
352
|
continue;
|
353
353
|
} else if (
|
354
|
-
curToNodeChild.
|
354
|
+
curToNodeChild.bV_ === FRAGMENT_NODE &&
|
355
355
|
curFromNodeChild.nodeType === COMMENT_NODE)
|
356
356
|
{
|
357
357
|
var content = curFromNodeChild.nodeValue;
|
@@ -418,7 +418,7 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
418
418
|
|
419
419
|
if (
|
420
420
|
curVFromNodeChild &&
|
421
|
-
curToNodeType === curVFromNodeChild.
|
421
|
+
curToNodeType === curVFromNodeChild.bV_ && (
|
422
422
|
curToNodeType !== ELEMENT_NODE ||
|
423
423
|
compareNodeNames(curVFromNodeChild, curToNodeChild)))
|
424
424
|
{
|
@@ -436,7 +436,7 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
436
436
|
|
437
437
|
if (
|
438
438
|
toNextSibling &&
|
439
|
-
toNextSibling.
|
439
|
+
toNextSibling.bU_ === curFromNodeKey)
|
440
440
|
{
|
441
441
|
// Single element swap
|
442
442
|
|
@@ -549,18 +549,18 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
549
549
|
|
550
550
|
if (
|
551
551
|
caseInsensitiveCompare(
|
552
|
-
curVFromNodeChild.
|
553
|
-
curToNodeChild.
|
552
|
+
curVFromNodeChild.ca_,
|
553
|
+
curToNodeChild.ca_
|
554
554
|
))
|
555
555
|
{
|
556
|
-
curVFromNodeChild.
|
556
|
+
curVFromNodeChild.ca_ = curToNodeChild.ca_;
|
557
557
|
}
|
558
558
|
} else {
|
559
559
|
// Skip over nodes that don't look like ours...
|
560
560
|
curFromNodeChild = fromNextSibling;
|
561
561
|
continue;
|
562
562
|
}
|
563
|
-
} else if (curFromNodeKey = curVFromNodeChild.
|
563
|
+
} else if (curFromNodeKey = curVFromNodeChild.bU_) {
|
564
564
|
// We have a keyed element here but our target VDOM node
|
565
565
|
// is not keyed so this not doesn't belong
|
566
566
|
isCompatible = false;
|
@@ -587,7 +587,7 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
587
587
|
{
|
588
588
|
// Both nodes being compared are Text or Comment nodes
|
589
589
|
isCompatible = true;
|
590
|
-
var curToNodeValue = curToNodeChild.
|
590
|
+
var curToNodeValue = curToNodeChild.cm_;
|
591
591
|
var curFromNodeValue = curFromNodeChild.nodeValue;
|
592
592
|
if (curFromNodeValue !== curToNodeValue) {
|
593
593
|
if (
|
@@ -638,10 +638,10 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
638
638
|
}
|
639
639
|
|
640
640
|
// We have processed all of the "to nodes".
|
641
|
-
if (fromNode.
|
641
|
+
if (fromNode.co_) {
|
642
642
|
// If we are in an unfinished fragment, we have reached the end of the nodes
|
643
643
|
// we were matching up and need to end the fragment
|
644
|
-
fromNode.
|
644
|
+
fromNode.co_(curFromNodeChild);
|
645
645
|
} else {
|
646
646
|
// If curFromNodeChild is non-null then we still have some from nodes
|
647
647
|
// left over that need to be removed
|
@@ -681,11 +681,11 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
681
681
|
}
|
682
682
|
|
683
683
|
function morphEl(fromEl, vFromEl, toEl, parentComponent) {
|
684
|
-
var nodeName = toEl.
|
685
|
-
var constId = toEl.
|
684
|
+
var nodeName = toEl.ca_;
|
685
|
+
var constId = toEl.cc_;
|
686
686
|
vElementByDOMNode.set(fromEl, toEl);
|
687
687
|
|
688
|
-
if (constId !== undefined && vFromEl.
|
688
|
+
if (constId !== undefined && vFromEl.cc_ === constId) {
|
689
689
|
return;
|
690
690
|
}
|
691
691
|
|
@@ -696,8 +696,8 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
696
696
|
}
|
697
697
|
|
698
698
|
if (nodeName === "textarea") {
|
699
|
-
if (toEl.
|
700
|
-
fromEl.value = toEl.
|
699
|
+
if (toEl.cb_ !== vFromEl.cb_) {
|
700
|
+
fromEl.value = toEl.cb_;
|
701
701
|
}
|
702
702
|
} else {
|
703
703
|
morphChildren(fromEl, toEl, parentComponent);
|
@@ -11,7 +11,7 @@ var specialHtmlRegexp = /[&<]/;
|
|
11
11
|
function virtualizeChildNodes(node, vdomParent, ownerComponent) {
|
12
12
|
var curChild = node.firstChild;
|
13
13
|
while (curChild) {
|
14
|
-
vdomParent.
|
14
|
+
vdomParent.bM_(virtualize(curChild, ownerComponent));
|
15
15
|
curChild = curChild.nextSibling;
|
16
16
|
}
|
17
17
|
}
|
@@ -19,7 +19,7 @@ function virtualizeChildNodes(node, vdomParent, ownerComponent) {
|
|
19
19
|
function virtualize(node, ownerComponent) {
|
20
20
|
switch (node.nodeType) {
|
21
21
|
case 1:
|
22
|
-
return VElement.
|
22
|
+
return VElement.cf_(node, virtualizeChildNodes, ownerComponent);
|
23
23
|
case 3:
|
24
24
|
return new VText(node.nodeValue, ownerComponent);
|
25
25
|
case 11:
|
@@ -38,7 +38,7 @@ function virtualizeHTML(html, ownerComponent) {
|
|
38
38
|
var curChild = parseHTML(html);
|
39
39
|
|
40
40
|
while (curChild) {
|
41
|
-
vdomFragment.
|
41
|
+
vdomFragment.bM_(virtualize(curChild, ownerComponent));
|
42
42
|
curChild = curChild.nextSibling;
|
43
43
|
}
|
44
44
|
|
@@ -65,18 +65,18 @@ Node_prototype.t = function (value) {
|
|
65
65
|
}
|
66
66
|
}
|
67
67
|
|
68
|
-
this.
|
69
|
-
return this.
|
68
|
+
this.bM_(vdomNode || new VText(value.toString()));
|
69
|
+
return this.cd_();
|
70
70
|
};
|
71
71
|
|
72
|
-
Node_prototype.
|
73
|
-
return this.
|
72
|
+
Node_prototype.bR_ = function () {
|
73
|
+
return this.bM_(new VDocumentFragment());
|
74
74
|
};
|
75
75
|
|
76
|
-
exports.
|
77
|
-
exports.
|
78
|
-
exports.
|
79
|
-
exports.
|
80
|
-
exports.
|
81
|
-
exports.
|
82
|
-
exports.
|
76
|
+
exports.bw_ = VDocumentFragment;
|
77
|
+
exports.bv_ = VElement;
|
78
|
+
exports.bx_ = VText;
|
79
|
+
exports.by_ = VComponent;
|
80
|
+
exports.bz_ = VFragment;
|
81
|
+
exports.cf_ = virtualize;
|
82
|
+
exports.bA_ = virtualizeHTML;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "marko",
|
3
|
-
"version": "5.33.
|
3
|
+
"version": "5.33.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",
|
@@ -61,11 +61,11 @@
|
|
61
61
|
"tags-html.d.ts"
|
62
62
|
],
|
63
63
|
"scripts": {
|
64
|
-
"build": "babel ./src --out-dir ./dist --copy-files --config-file ../../babel.config.js --env-name=production"
|
64
|
+
"build": "babel ./src --out-dir ./dist --extensions .js --copy-files --config-file ../../babel.config.js --env-name=production"
|
65
65
|
},
|
66
66
|
"dependencies": {
|
67
|
-
"@marko/compiler": "^5.35.
|
68
|
-
"@marko/translator-default": "^5.32.
|
67
|
+
"@marko/compiler": "^5.35.4",
|
68
|
+
"@marko/translator-default": "^5.32.3",
|
69
69
|
"app-module-path": "^2.2.0",
|
70
70
|
"argly": "^1.2.0",
|
71
71
|
"browser-refresh-client": "1.1.4",
|
@@ -0,0 +1 @@
|
|
1
|
+
require("./runtime-dom.js").p(require("@marko/runtime-tags/debug/dom").compat);
|
@@ -0,0 +1 @@
|
|
1
|
+
require("./runtime-dom.js").p(require("@marko/runtime-tags/dom").compat);
|
@@ -0,0 +1 @@
|
|
1
|
+
exports.s = require("./runtime-html.js").p(require("@marko/runtime-tags/html"));
|
@@ -0,0 +1,231 @@
|
|
1
|
+
const { ___componentLookup } = require("@internal/components-util");
|
2
|
+
const {
|
3
|
+
___getComponentsContext,
|
4
|
+
} = require("../../components/ComponentsContext");
|
5
|
+
const defineComponent = require("../../components/defineComponent");
|
6
|
+
const { r: registerComponent } = require("../../components/registry");
|
7
|
+
const createRenderer = require("../../components/renderer");
|
8
|
+
const defaultCreateOut = require("../../createOut");
|
9
|
+
const morphdom = require("../../vdom/morphdom");
|
10
|
+
const { ___createFragmentNode } = require("../../vdom/morphdom/fragment");
|
11
|
+
const dynamicTag = require("../dynamic-tag");
|
12
|
+
|
13
|
+
exports.p = function (domCompat) {
|
14
|
+
dynamicTag.___runtimeCompat = function tagsToVdom(
|
15
|
+
renderer,
|
16
|
+
renderBody,
|
17
|
+
args,
|
18
|
+
) {
|
19
|
+
const tagsRenderer = domCompat.resolveRenderer(renderer || renderBody);
|
20
|
+
|
21
|
+
if (tagsRenderer) {
|
22
|
+
return (input, out) =>
|
23
|
+
TagsCompat({ i: args ? args : input, r: tagsRenderer }, out);
|
24
|
+
}
|
25
|
+
|
26
|
+
return renderer;
|
27
|
+
};
|
28
|
+
|
29
|
+
const TagsCompatId = "tags-compat";
|
30
|
+
const TagsCompat = createRenderer(
|
31
|
+
function (_, out, componentDef, component) {
|
32
|
+
const isHydrate =
|
33
|
+
___getComponentsContext(out).___globalContext.___isHydrate;
|
34
|
+
const input = Array.isArray(_.i) ? _.i : [_.i];
|
35
|
+
const tagsRenderer = domCompat.resolveRenderer(_.r);
|
36
|
+
const newNode = domCompat.render(
|
37
|
+
isHydrate,
|
38
|
+
out,
|
39
|
+
component,
|
40
|
+
tagsRenderer,
|
41
|
+
input,
|
42
|
+
);
|
43
|
+
|
44
|
+
out.bf(out.___assignedKey, component, !newNode);
|
45
|
+
if (newNode) {
|
46
|
+
out.node({ ___actualize: () => newNode });
|
47
|
+
}
|
48
|
+
out.ef();
|
49
|
+
},
|
50
|
+
// eslint-disable-next-line no-constant-condition
|
51
|
+
"MARKO_DEBUG"
|
52
|
+
? {
|
53
|
+
t: TagsCompatId,
|
54
|
+
d: true,
|
55
|
+
}
|
56
|
+
: {
|
57
|
+
t: TagsCompatId,
|
58
|
+
},
|
59
|
+
{},
|
60
|
+
);
|
61
|
+
|
62
|
+
registerComponent(TagsCompatId, () => ({
|
63
|
+
_: TagsCompat,
|
64
|
+
Component: defineComponent(
|
65
|
+
{
|
66
|
+
onMount: domCompat.runComponentEffects,
|
67
|
+
onUpdate: domCompat.runComponentEffects,
|
68
|
+
},
|
69
|
+
TagsCompat,
|
70
|
+
),
|
71
|
+
}));
|
72
|
+
|
73
|
+
// (
|
74
|
+
// nodeAccessor: Accessor,
|
75
|
+
// dynamicTagAttrs?: IntersectionSignal,
|
76
|
+
// intersection?: IntersectionSignal,
|
77
|
+
// valueWithIntersection?: ValueSignal
|
78
|
+
// )
|
79
|
+
|
80
|
+
const rendererCache = new WeakMap();
|
81
|
+
|
82
|
+
domCompat.patchConditionals((conditional) => (...args) => {
|
83
|
+
const signal = conditional(...args);
|
84
|
+
const hasAttrs = args.length > 1;
|
85
|
+
return (scope, renderer, clean) => {
|
86
|
+
return signal(scope, create5to6Renderer(renderer, hasAttrs), clean);
|
87
|
+
};
|
88
|
+
});
|
89
|
+
|
90
|
+
function create5to6Renderer(renderer, hasAttrs) {
|
91
|
+
let newRenderer = renderer;
|
92
|
+
if (renderer && typeof renderer !== "string") {
|
93
|
+
const rendererFromAnywhere =
|
94
|
+
renderer._ ||
|
95
|
+
renderer.render ||
|
96
|
+
(renderer.renderer && renderer.renderer.renderer) ||
|
97
|
+
renderer.renderer;
|
98
|
+
|
99
|
+
if (!domCompat.isRenderer(rendererFromAnywhere || renderer)) {
|
100
|
+
newRenderer = rendererCache.get(renderer);
|
101
|
+
if (!newRenderer) {
|
102
|
+
const { Component } = renderer;
|
103
|
+
if (Component) {
|
104
|
+
const setCustomEvents = Component.prototype.___setCustomEvents;
|
105
|
+
Component.prototype.___setCustomEvents = function (
|
106
|
+
customEvents,
|
107
|
+
scopeId,
|
108
|
+
) {
|
109
|
+
for (const customEvent of customEvents) {
|
110
|
+
customEvent[1] = domCompat.resolveRenderer(customEvent[1]);
|
111
|
+
}
|
112
|
+
|
113
|
+
setCustomEvents.call(this, customEvents, scopeId);
|
114
|
+
};
|
115
|
+
}
|
116
|
+
newRenderer = domCompat.createRenderer(
|
117
|
+
(scope) => {
|
118
|
+
if (!hasAttrs) {
|
119
|
+
renderAndMorph(scope, rendererFromAnywhere, renderer, {});
|
120
|
+
}
|
121
|
+
},
|
122
|
+
() => {
|
123
|
+
const realFragment = document.createDocumentFragment();
|
124
|
+
___createFragmentNode(null, null, realFragment);
|
125
|
+
return realFragment;
|
126
|
+
},
|
127
|
+
(scope, input, clean) => {
|
128
|
+
if (clean) return;
|
129
|
+
renderAndMorph(scope, rendererFromAnywhere, renderer, input);
|
130
|
+
},
|
131
|
+
);
|
132
|
+
rendererCache.set(renderer, newRenderer);
|
133
|
+
}
|
134
|
+
}
|
135
|
+
}
|
136
|
+
return newRenderer;
|
137
|
+
}
|
138
|
+
|
139
|
+
domCompat.register("@marko/tags-compat-5-to-6", create5to6Renderer);
|
140
|
+
|
141
|
+
function renderAndMorph(scope, renderer, renderBody, input) {
|
142
|
+
const out = defaultCreateOut();
|
143
|
+
let host = domCompat.getStartNode(scope);
|
144
|
+
let rootNode = host.fragment;
|
145
|
+
if (!rootNode) {
|
146
|
+
const component = (scope.marko5Component = ___componentLookup[scope.m5c]);
|
147
|
+
rootNode = component.___rootNode;
|
148
|
+
host = rootNode.startNode;
|
149
|
+
domCompat.setScopeNodes(host, rootNode.endNode);
|
150
|
+
}
|
151
|
+
const existingComponent = scope.marko5Component;
|
152
|
+
const componentsContext = ___getComponentsContext(out);
|
153
|
+
const globalComponentsContext = componentsContext.___globalContext;
|
154
|
+
let customEvents;
|
155
|
+
globalComponentsContext.___rerenderComponent = existingComponent;
|
156
|
+
out.sync();
|
157
|
+
if (renderer) {
|
158
|
+
const [rawInput] = input;
|
159
|
+
const normalizedInput = {};
|
160
|
+
|
161
|
+
for (const key in rawInput) {
|
162
|
+
let value = rawInput[key];
|
163
|
+
if (key.startsWith("on")) {
|
164
|
+
const c = key[2];
|
165
|
+
customEvents = customEvents || {};
|
166
|
+
customEvents[(c === "-" ? "" : c.toLowerCase()) + key.slice(3)] = [
|
167
|
+
value,
|
168
|
+
];
|
169
|
+
} else {
|
170
|
+
normalizedInput[key] = rawInput[key];
|
171
|
+
}
|
172
|
+
}
|
173
|
+
|
174
|
+
renderer(normalizedInput, out);
|
175
|
+
} else {
|
176
|
+
RenderBodyComponent({ renderBody, args: input }, out);
|
177
|
+
}
|
178
|
+
|
179
|
+
domCompat.queueEffect(scope, () => {
|
180
|
+
const targetNode = out.___getOutput().___firstChild;
|
181
|
+
morphdom(rootNode, targetNode, host, componentsContext);
|
182
|
+
const componentDefs = componentsContext.___initComponents(
|
183
|
+
getRootNode(host),
|
184
|
+
);
|
185
|
+
const component = componentDefs[0].___component;
|
186
|
+
component.___rootNode = rootNode;
|
187
|
+
component.___input = input[0];
|
188
|
+
component.___customEvents = customEvents;
|
189
|
+
scope.marko5Component = component;
|
190
|
+
});
|
191
|
+
}
|
192
|
+
|
193
|
+
function getRootNode(el) {
|
194
|
+
var cur = el;
|
195
|
+
while (cur.parentNode) cur = cur.parentNode;
|
196
|
+
return cur;
|
197
|
+
}
|
198
|
+
|
199
|
+
const RenderBodyComponentId = "renderbody-renderer";
|
200
|
+
const RenderBodyComponent = createRenderer(
|
201
|
+
function (input, out, _componentDef) {
|
202
|
+
dynamicTag(
|
203
|
+
out,
|
204
|
+
input.renderBody,
|
205
|
+
null,
|
206
|
+
null,
|
207
|
+
input.args,
|
208
|
+
null,
|
209
|
+
_componentDef,
|
210
|
+
"0",
|
211
|
+
);
|
212
|
+
},
|
213
|
+
// eslint-disable-next-line no-constant-condition
|
214
|
+
"MARKO_DEBUG"
|
215
|
+
? {
|
216
|
+
t: RenderBodyComponentId,
|
217
|
+
i: true,
|
218
|
+
d: true,
|
219
|
+
}
|
220
|
+
: {
|
221
|
+
t: RenderBodyComponentId,
|
222
|
+
i: true,
|
223
|
+
},
|
224
|
+
{},
|
225
|
+
);
|
226
|
+
|
227
|
+
registerComponent(RenderBodyComponentId, () => ({
|
228
|
+
_: RenderBodyComponent,
|
229
|
+
Component: defineComponent({}, RenderBodyComponent),
|
230
|
+
}));
|
231
|
+
};
|