marko 5.36.5 → 5.37.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.
- package/dist/compiler/index.js +11 -11
- package/dist/core-tags/components/init-components-tag.js +4 -4
- package/dist/core-tags/components/preferred-script-location-tag.js +2 -2
- package/dist/core-tags/core/__flush_here_and_after__.js +1 -1
- package/dist/core-tags/core/await/AsyncValue.js +21 -21
- package/dist/core-tags/core/await/renderer.js +24 -24
- package/dist/core-tags/core/await/reorderer-renderer.js +6 -6
- package/dist/node-require/browser-refresh.js +18 -1
- package/dist/node-require/index.js +7 -7
- package/dist/node_modules/@internal/components-beginComponent/index-browser.js +5 -5
- package/dist/node_modules/@internal/components-beginComponent/index.js +12 -12
- package/dist/node_modules/@internal/components-define-widget-legacy/index-browser.js +99 -99
- package/dist/node_modules/@internal/components-define-widget-legacy/index.js +3 -3
- package/dist/node_modules/@internal/components-endComponent/index.js +3 -3
- package/dist/node_modules/@internal/components-entry/index-browser.js +2 -2
- package/dist/node_modules/@internal/components-entry/index.js +29 -29
- package/dist/node_modules/@internal/components-entry-legacy/index-browser.js +13 -13
- package/dist/node_modules/@internal/components-entry-legacy/index.js +1 -1
- package/dist/node_modules/@internal/components-registry/index-browser.js +102 -102
- package/dist/node_modules/@internal/components-registry/index.js +2 -2
- package/dist/node_modules/@internal/components-util/index-browser.js +20 -20
- package/dist/node_modules/@internal/components-util/index.js +24 -20
- package/dist/node_modules/@internal/create-readable/index-browser.js +1 -1
- package/dist/node_modules/@internal/create-readable/index.js +9 -9
- package/dist/node_modules/@internal/preserve-tag/index-browser.js +8 -8
- package/dist/node_modules/@internal/preserve-tag/index.js +6 -6
- package/dist/node_modules/@internal/set-immediate/index-browser.js +2 -2
- package/dist/node_modules/@internal/set-immediate/index-worker.js +3 -3
- package/dist/node_modules/@internal/set-immediate/index.js +3 -3
- package/dist/runtime/RenderResult.js +24 -24
- package/dist/runtime/components/Component.js +163 -163
- package/dist/runtime/components/ComponentDef.js +34 -34
- package/dist/runtime/components/ComponentsContext.js +20 -20
- package/dist/runtime/components/GlobalComponentsContext.js +4 -4
- package/dist/runtime/components/KeySequence.js +3 -3
- package/dist/runtime/components/ServerComponent.js +17 -17
- package/dist/runtime/components/State.js +28 -28
- package/dist/runtime/components/attach-detach.js +8 -8
- package/dist/runtime/components/defineComponent.js +5 -5
- package/dist/runtime/components/dom-data.js +6 -6
- package/dist/runtime/components/event-delegation.js +10 -10
- package/dist/runtime/components/legacy/defineComponent-legacy.js +1 -1
- package/dist/runtime/components/legacy/defineRenderer-legacy.js +25 -25
- package/dist/runtime/components/legacy/dependencies/index.js +10 -10
- package/dist/runtime/components/legacy/renderer-legacy.js +56 -56
- package/dist/runtime/components/renderer.js +45 -45
- package/dist/runtime/components/update-manager.js +4 -4
- package/dist/runtime/createOut.js +1 -1
- package/dist/runtime/dom-insert.js +5 -5
- package/dist/runtime/helpers/_change-case.js +2 -2
- package/dist/runtime/helpers/dynamic-tag.js +33 -33
- package/dist/runtime/helpers/render-tag.js +1 -1
- package/dist/runtime/helpers/serialize-noop.js +2 -2
- package/dist/runtime/helpers/style-value.js +1 -1
- package/dist/runtime/helpers/tags-compat/runtime-dom.js +35 -35
- package/dist/runtime/helpers/tags-compat/runtime-html.js +16 -16
- package/dist/runtime/html/AsyncStream.js +28 -28
- package/dist/runtime/html/BufferedWriter.js +2 -2
- package/dist/runtime/html/StringWriter.js +2 -2
- package/dist/runtime/html/helpers/_dynamic-attr.js +2 -2
- package/dist/runtime/html/helpers/attr.js +11 -11
- package/dist/runtime/html/helpers/attrs.js +6 -6
- package/dist/runtime/html/helpers/data-marko.js +6 -6
- package/dist/runtime/html/helpers/escape-quotes.js +2 -2
- package/dist/runtime/html/helpers/escape-xml.js +1 -1
- package/dist/runtime/html/helpers/merge-attrs.js +11 -11
- package/dist/runtime/html/helpers/props-script.js +1 -1
- package/dist/runtime/html/index.js +2 -2
- package/dist/runtime/renderable.js +5 -5
- package/dist/runtime/vdom/AsyncVDOMBuilder.js +100 -100
- package/dist/runtime/vdom/VComment.js +7 -7
- package/dist/runtime/vdom/VComponent.js +5 -5
- package/dist/runtime/vdom/VDocumentFragment.js +8 -8
- package/dist/runtime/vdom/VElement.js +52 -52
- package/dist/runtime/vdom/VFragment.js +9 -9
- package/dist/runtime/vdom/VNode.js +34 -34
- package/dist/runtime/vdom/VText.js +8 -8
- package/dist/runtime/vdom/helpers/attrs.js +6 -6
- package/dist/runtime/vdom/helpers/const-element.js +3 -3
- package/dist/runtime/vdom/hot-reload.js +20 -20
- package/dist/runtime/vdom/index.js +2 -2
- package/dist/runtime/vdom/morphdom/fragment.js +10 -10
- package/dist/runtime/vdom/morphdom/helpers.js +5 -5
- package/dist/runtime/vdom/morphdom/index.js +81 -81
- package/dist/runtime/vdom/vdom.js +15 -15
- package/dist/taglib/index.js +7 -7
- package/dist/translator/cdata/index.js +15 -0
- package/dist/translator/cdata/index[html].js +15 -0
- package/dist/translator/cdata/index[vdom].js +12 -0
- package/dist/translator/class.js +65 -0
- package/dist/translator/comment/index.js +15 -0
- package/dist/translator/comment/index[html].js +17 -0
- package/dist/translator/comment/index[vdom].js +3 -0
- package/dist/translator/declaration/index.js +15 -0
- package/dist/translator/declaration/index[html].js +12 -0
- package/dist/translator/declaration/index[vdom].js +3 -0
- package/dist/translator/document-type/index.js +15 -0
- package/dist/translator/document-type/index[html].js +12 -0
- package/dist/translator/document-type/index[vdom].js +3 -0
- package/dist/translator/index.js +551 -0
- package/dist/translator/placeholder/index.js +15 -0
- package/dist/translator/placeholder/index[html].js +93 -0
- package/dist/translator/placeholder/index[vdom].js +22 -0
- package/dist/translator/scriptlet.js +4 -0
- package/dist/translator/tag/attribute/directives/class.js +42 -0
- package/dist/translator/tag/attribute/directives/index.js +15 -0
- package/dist/translator/tag/attribute/directives/no-update-body-if.js +15 -0
- package/dist/translator/tag/attribute/directives/no-update-body.js +10 -0
- package/dist/translator/tag/attribute/directives/no-update-if.js +12 -0
- package/dist/translator/tag/attribute/directives/no-update.js +48 -0
- package/dist/translator/tag/attribute/directives/style.js +42 -0
- package/dist/translator/tag/attribute/index.js +150 -0
- package/dist/translator/tag/attribute/modifiers/index.js +7 -0
- package/dist/translator/tag/attribute/modifiers/no-update.js +14 -0
- package/dist/translator/tag/attribute/modifiers/scoped.js +23 -0
- package/dist/translator/tag/attribute-tag.js +149 -0
- package/dist/translator/tag/custom-tag.js +146 -0
- package/dist/translator/tag/dynamic-tag.js +74 -0
- package/dist/translator/tag/index.js +287 -0
- package/dist/translator/tag/macro-tag.js +7 -0
- package/dist/translator/tag/native-tag.js +27 -0
- package/dist/translator/tag/native-tag[html]/attributes.js +151 -0
- package/dist/translator/tag/native-tag[html]/index.js +221 -0
- package/dist/translator/tag/native-tag[vdom]/attributes.js +105 -0
- package/dist/translator/tag/native-tag[vdom]/index.js +189 -0
- package/dist/translator/tag/util.js +246 -0
- package/dist/translator/taglib/core/conditional/translate-else-if.js +20 -0
- package/dist/translator/taglib/core/conditional/translate-else.js +20 -0
- package/dist/translator/taglib/core/conditional/translate-if.js +8 -0
- package/dist/translator/taglib/core/conditional/util.js +41 -0
- package/dist/translator/taglib/core/index.js +474 -0
- package/dist/translator/taglib/core/macro/parse.js +17 -0
- package/dist/translator/taglib/core/macro/translate.js +48 -0
- package/dist/translator/taglib/core/parse-class.js +79 -0
- package/dist/translator/taglib/core/parse-export.js +14 -0
- package/dist/translator/taglib/core/parse-import.js +14 -0
- package/dist/translator/taglib/core/parse-module-code.js +18 -0
- package/dist/translator/taglib/core/parse-static.js +18 -0
- package/dist/translator/taglib/core/transform-style.js +66 -0
- package/dist/translator/taglib/core/translate-await.js +41 -0
- package/dist/translator/taglib/core/translate-body.js +17 -0
- package/dist/translator/taglib/core/translate-for.js +156 -0
- package/dist/translator/taglib/core/translate-html-comment.js +52 -0
- package/dist/translator/taglib/core/translate-include-content.js +53 -0
- package/dist/translator/taglib/core/translate-server-only.js +5 -0
- package/dist/translator/taglib/core/translate-while.js +32 -0
- package/dist/translator/taglib/index.js +6 -0
- package/dist/translator/taglib/migrate/all-templates.js +46 -0
- package/dist/translator/taglib/migrate/index.js +5 -0
- package/dist/translator/text/index.js +10 -0
- package/dist/translator/text/index[html].js +12 -0
- package/dist/translator/text/index[vdom].js +20 -0
- package/dist/translator/util/add-dependencies.js +329 -0
- package/dist/translator/util/escape-regexp.js +4 -0
- package/dist/translator/util/get-component-files.js +86 -0
- package/dist/translator/util/html-out-write.js +15 -0
- package/dist/translator/util/key-manager.js +176 -0
- package/dist/translator/util/optimize-html-writes.js +52 -0
- package/dist/translator/util/optimize-vdom-create.js +164 -0
- package/dist/translator/util/plugin-hooks.js +22 -0
- package/dist/translator/util/runtime-flags.js +3 -0
- package/dist/translator/util/vdom-out-write.js +10 -0
- package/dist/translator/util/with-previous-location.js +6 -0
- package/package.json +7 -4
- package/src/taglib/index.js +2 -2
- package/src/translator/cdata/index.js +15 -0
- package/src/translator/cdata/index[html].js +15 -0
- package/src/translator/cdata/index[vdom].js +12 -0
- package/src/translator/class.js +65 -0
- package/src/translator/comment/index.js +15 -0
- package/src/translator/comment/index[html].js +17 -0
- package/src/translator/comment/index[vdom].js +3 -0
- package/src/translator/declaration/index.js +15 -0
- package/src/translator/declaration/index[html].js +12 -0
- package/src/translator/declaration/index[vdom].js +3 -0
- package/src/translator/document-type/index.js +15 -0
- package/src/translator/document-type/index[html].js +12 -0
- package/src/translator/document-type/index[vdom].js +3 -0
- package/src/translator/index.js +551 -0
- package/src/translator/placeholder/index.js +15 -0
- package/src/translator/placeholder/index[html].js +93 -0
- package/src/translator/placeholder/index[vdom].js +22 -0
- package/src/translator/scriptlet.js +4 -0
- package/src/translator/tag/attribute/directives/class.js +42 -0
- package/src/translator/tag/attribute/directives/index.js +15 -0
- package/src/translator/tag/attribute/directives/no-update-body-if.js +15 -0
- package/src/translator/tag/attribute/directives/no-update-body.js +10 -0
- package/src/translator/tag/attribute/directives/no-update-if.js +12 -0
- package/src/translator/tag/attribute/directives/no-update.js +48 -0
- package/src/translator/tag/attribute/directives/style.js +42 -0
- package/src/translator/tag/attribute/index.js +150 -0
- package/src/translator/tag/attribute/modifiers/index.js +7 -0
- package/src/translator/tag/attribute/modifiers/no-update.js +14 -0
- package/src/translator/tag/attribute/modifiers/scoped.js +23 -0
- package/src/translator/tag/attribute-tag.js +149 -0
- package/src/translator/tag/custom-tag.js +146 -0
- package/src/translator/tag/dynamic-tag.js +74 -0
- package/src/translator/tag/index.js +287 -0
- package/src/translator/tag/macro-tag.js +7 -0
- package/src/translator/tag/native-tag.js +27 -0
- package/src/translator/tag/native-tag[html]/attributes.js +151 -0
- package/src/translator/tag/native-tag[html]/index.js +221 -0
- package/src/translator/tag/native-tag[vdom]/attributes.js +105 -0
- package/src/translator/tag/native-tag[vdom]/index.js +189 -0
- package/src/translator/tag/util.js +246 -0
- package/src/translator/taglib/core/conditional/translate-else-if.js +20 -0
- package/src/translator/taglib/core/conditional/translate-else.js +20 -0
- package/src/translator/taglib/core/conditional/translate-if.js +8 -0
- package/src/translator/taglib/core/conditional/util.js +41 -0
- package/src/translator/taglib/core/index.js +474 -0
- package/src/translator/taglib/core/macro/parse.js +17 -0
- package/src/translator/taglib/core/macro/translate.js +48 -0
- package/src/translator/taglib/core/parse-class.js +79 -0
- package/src/translator/taglib/core/parse-export.js +14 -0
- package/src/translator/taglib/core/parse-import.js +14 -0
- package/src/translator/taglib/core/parse-module-code.js +18 -0
- package/src/translator/taglib/core/parse-static.js +18 -0
- package/src/translator/taglib/core/transform-style.js +66 -0
- package/src/translator/taglib/core/translate-await.js +41 -0
- package/src/translator/taglib/core/translate-body.js +17 -0
- package/src/translator/taglib/core/translate-for.js +156 -0
- package/src/translator/taglib/core/translate-html-comment.js +52 -0
- package/src/translator/taglib/core/translate-include-content.js +53 -0
- package/src/translator/taglib/core/translate-server-only.js +5 -0
- package/src/translator/taglib/core/translate-while.js +32 -0
- package/src/translator/taglib/index.js +7 -0
- package/src/translator/taglib/migrate/all-templates.js +46 -0
- package/src/translator/taglib/migrate/index.js +5 -0
- package/src/translator/text/index.js +10 -0
- package/src/translator/text/index[html].js +12 -0
- package/src/translator/text/index[vdom].js +20 -0
- package/src/translator/util/add-dependencies.js +329 -0
- package/src/translator/util/escape-regexp.js +4 -0
- package/src/translator/util/get-component-files.js +86 -0
- package/src/translator/util/html-out-write.js +15 -0
- package/src/translator/util/key-manager.js +176 -0
- package/src/translator/util/optimize-html-writes.js +52 -0
- package/src/translator/util/optimize-vdom-create.js +164 -0
- package/src/translator/util/plugin-hooks.js +22 -0
- package/src/translator/util/runtime-flags.js +3 -0
- package/src/translator/util/vdom-out-write.js +10 -0
- package/src/translator/util/with-previous-location.js +6 -0
- package/translator/index.d.ts +7 -0
- package/translator/package.json +5 -0
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var componentsUtil = require("@internal/components-util");
|
|
3
|
-
var existingComponentLookup = componentsUtil.
|
|
4
|
-
var destroyNodeRecursive = componentsUtil.
|
|
3
|
+
var existingComponentLookup = componentsUtil.___componentLookup;
|
|
4
|
+
var destroyNodeRecursive = componentsUtil.___destroyNodeRecursive;
|
|
5
5
|
var addComponentRootToKeyedElements =
|
|
6
|
-
componentsUtil.
|
|
7
|
-
var normalizeComponentKey = componentsUtil.
|
|
6
|
+
componentsUtil.___addComponentRootToKeyedElements;
|
|
7
|
+
var normalizeComponentKey = componentsUtil.___normalizeComponentKey;
|
|
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").___VElement;
|
|
12
12
|
var fragment = require("./fragment");
|
|
13
13
|
var helpers = require("./helpers");
|
|
14
14
|
var isTextOnly = require("../is-text-only");
|
|
15
|
-
var virtualizeElement = VElement.
|
|
16
|
-
var morphAttrs = VElement.
|
|
17
|
-
var keysByDOMNode = domData.
|
|
18
|
-
var componentByDOMNode = domData.
|
|
19
|
-
var vElementByDOMNode = domData.
|
|
20
|
-
var detachedByDOMNode = domData.
|
|
21
|
-
|
|
22
|
-
var insertBefore = helpers.
|
|
23
|
-
var insertAfter = helpers.
|
|
24
|
-
var nextSibling = helpers.
|
|
25
|
-
var firstChild = helpers.
|
|
26
|
-
var removeChild = helpers.
|
|
27
|
-
var createFragmentNode = fragment.
|
|
28
|
-
var beginFragmentNode = fragment.
|
|
15
|
+
var virtualizeElement = VElement.___virtualize;
|
|
16
|
+
var morphAttrs = VElement.___morphAttrs;
|
|
17
|
+
var keysByDOMNode = domData.___keyByDOMNode;
|
|
18
|
+
var componentByDOMNode = domData.___componentByDOMNode;
|
|
19
|
+
var vElementByDOMNode = domData.___vElementByDOMNode;
|
|
20
|
+
var detachedByDOMNode = domData.___detachedByDOMNode;
|
|
21
|
+
|
|
22
|
+
var insertBefore = helpers.___insertBefore;
|
|
23
|
+
var insertAfter = helpers.___insertAfter;
|
|
24
|
+
var nextSibling = helpers.___nextSibling;
|
|
25
|
+
var firstChild = helpers.___firstChild;
|
|
26
|
+
var removeChild = helpers.___removeChild;
|
|
27
|
+
var createFragmentNode = fragment.___createFragmentNode;
|
|
28
|
+
var beginFragmentNode = fragment.___beginFragmentNode;
|
|
29
29
|
|
|
30
30
|
var ELEMENT_NODE = 1;
|
|
31
31
|
var TEXT_NODE = 3;
|
|
@@ -43,7 +43,7 @@ function isAutoKey(key) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
function compareNodeNames(fromEl, toEl) {
|
|
46
|
-
return fromEl.
|
|
46
|
+
return fromEl.___nodeName === toEl.___nodeName;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
function caseInsensitiveCompare(a, b) {
|
|
@@ -52,7 +52,7 @@ function caseInsensitiveCompare(a, b) {
|
|
|
52
52
|
|
|
53
53
|
function onNodeAdded(node, componentsContext) {
|
|
54
54
|
if (node.nodeType === ELEMENT_NODE) {
|
|
55
|
-
eventDelegation.
|
|
55
|
+
eventDelegation.___handleNodeAttach(node, componentsContext);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -62,8 +62,8 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
|
62
62
|
var keySequences = Object.create(null);
|
|
63
63
|
|
|
64
64
|
if (componentsContext) {
|
|
65
|
-
globalComponentsContext = componentsContext.
|
|
66
|
-
isHydrate = globalComponentsContext.
|
|
65
|
+
globalComponentsContext = componentsContext.___globalContext;
|
|
66
|
+
isHydrate = globalComponentsContext.___isHydrate;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
function insertVirtualNodeBefore(
|
|
@@ -74,21 +74,21 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
|
74
74
|
ownerComponent,
|
|
75
75
|
parentComponent)
|
|
76
76
|
{
|
|
77
|
-
var realNode = vNode.
|
|
77
|
+
var realNode = vNode.___actualize(host, parentEl.namespaceURI);
|
|
78
78
|
insertBefore(realNode, referenceEl, parentEl);
|
|
79
79
|
|
|
80
80
|
if (
|
|
81
|
-
vNode.
|
|
82
|
-
vNode.
|
|
81
|
+
vNode.___nodeType === ELEMENT_NODE ||
|
|
82
|
+
vNode.___nodeType === FRAGMENT_NODE)
|
|
83
83
|
{
|
|
84
84
|
if (key) {
|
|
85
85
|
keysByDOMNode.set(realNode, key);
|
|
86
|
-
(isAutoKey(key) ? parentComponent : ownerComponent).
|
|
86
|
+
(isAutoKey(key) ? parentComponent : ownerComponent).___keyedElements[
|
|
87
87
|
key] =
|
|
88
88
|
realNode;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
if (!isTextOnly(vNode.
|
|
91
|
+
if (!isTextOnly(vNode.___nodeName)) {
|
|
92
92
|
morphChildren(realNode, vNode, parentComponent);
|
|
93
93
|
}
|
|
94
94
|
|
|
@@ -105,7 +105,7 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
|
105
105
|
ownerComponent,
|
|
106
106
|
parentComponent)
|
|
107
107
|
{
|
|
108
|
-
var rootNode = component.
|
|
108
|
+
var rootNode = component.___rootNode = insertBefore(
|
|
109
109
|
createFragmentNode(),
|
|
110
110
|
referenceNode,
|
|
111
111
|
referenceNodeParentEl
|
|
@@ -115,7 +115,7 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
|
115
115
|
if (key && ownerComponent) {
|
|
116
116
|
key = normalizeComponentKey(key, parentComponent.id);
|
|
117
117
|
addComponentRootToKeyedElements(
|
|
118
|
-
ownerComponent.
|
|
118
|
+
ownerComponent.___keyedElements,
|
|
119
119
|
key,
|
|
120
120
|
rootNode,
|
|
121
121
|
component.id
|
|
@@ -127,7 +127,7 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
function morphComponent(component, vComponent) {
|
|
130
|
-
morphChildren(component.
|
|
130
|
+
morphChildren(component.___rootNode, vComponent, component);
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
var detachedNodes = [];
|
|
@@ -148,7 +148,7 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
|
148
148
|
|
|
149
149
|
function morphChildren(fromNode, toNode, parentComponent) {
|
|
150
150
|
var curFromNodeChild = firstChild(fromNode);
|
|
151
|
-
var curToNodeChild = toNode.
|
|
151
|
+
var curToNodeChild = toNode.___firstChild;
|
|
152
152
|
|
|
153
153
|
var curToNodeKey;
|
|
154
154
|
var curFromNodeKey;
|
|
@@ -162,27 +162,27 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
|
162
162
|
var fromComponent;
|
|
163
163
|
|
|
164
164
|
outer: while (curToNodeChild) {
|
|
165
|
-
toNextSibling = curToNodeChild.
|
|
166
|
-
curToNodeType = curToNodeChild.
|
|
167
|
-
curToNodeKey = curToNodeChild.
|
|
165
|
+
toNextSibling = curToNodeChild.___nextSibling;
|
|
166
|
+
curToNodeType = curToNodeChild.___nodeType;
|
|
167
|
+
curToNodeKey = curToNodeChild.___key;
|
|
168
168
|
|
|
169
169
|
// Skip <!doctype>
|
|
170
170
|
if (curFromNodeChild && curFromNodeChild.nodeType === DOCTYPE_NODE) {
|
|
171
171
|
curFromNodeChild = nextSibling(curFromNodeChild);
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
var ownerComponent = curToNodeChild.
|
|
174
|
+
var ownerComponent = curToNodeChild.___ownerComponent || parentComponent;
|
|
175
175
|
var referenceComponent;
|
|
176
176
|
|
|
177
177
|
if (curToNodeType === COMPONENT_NODE) {
|
|
178
|
-
var component = curToNodeChild.
|
|
178
|
+
var component = curToNodeChild.___component;
|
|
179
179
|
if (
|
|
180
180
|
(matchingFromComponent = existingComponentLookup[component.id]) ===
|
|
181
181
|
undefined)
|
|
182
182
|
{
|
|
183
183
|
if (isHydrate) {
|
|
184
184
|
var rootNode = beginFragmentNode(curFromNodeChild, fromNode);
|
|
185
|
-
component.
|
|
185
|
+
component.___rootNode = rootNode;
|
|
186
186
|
componentByDOMNode.set(rootNode, component);
|
|
187
187
|
|
|
188
188
|
if (ownerComponent && curToNodeKey) {
|
|
@@ -191,7 +191,7 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
|
191
191
|
parentComponent.id
|
|
192
192
|
);
|
|
193
193
|
addComponentRootToKeyedElements(
|
|
194
|
-
ownerComponent.
|
|
194
|
+
ownerComponent.___keyedElements,
|
|
195
195
|
curToNodeKey,
|
|
196
196
|
rootNode,
|
|
197
197
|
component.id
|
|
@@ -215,17 +215,17 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
|
215
215
|
);
|
|
216
216
|
}
|
|
217
217
|
} else {
|
|
218
|
-
if (matchingFromComponent.
|
|
218
|
+
if (matchingFromComponent.___rootNode !== curFromNodeChild) {
|
|
219
219
|
if (
|
|
220
220
|
curFromNodeChild && (
|
|
221
221
|
fromComponent = componentByDOMNode.get(curFromNodeChild)) &&
|
|
222
|
-
globalComponentsContext.
|
|
222
|
+
globalComponentsContext.___renderedComponentsById[
|
|
223
223
|
fromComponent.id] ===
|
|
224
224
|
undefined)
|
|
225
225
|
{
|
|
226
226
|
// The component associated with the current real DOM node was not rendered
|
|
227
227
|
// so we should just remove it out of the real DOM by destroying it
|
|
228
|
-
curFromNodeChild = nextSibling(fromComponent.
|
|
228
|
+
curFromNodeChild = nextSibling(fromComponent.___rootNode);
|
|
229
229
|
destroyComponent(fromComponent);
|
|
230
230
|
continue;
|
|
231
231
|
}
|
|
@@ -233,7 +233,7 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
|
233
233
|
// We need to move the existing component into
|
|
234
234
|
// the correct location
|
|
235
235
|
insertBefore(
|
|
236
|
-
matchingFromComponent.
|
|
236
|
+
matchingFromComponent.___rootNode,
|
|
237
237
|
curFromNodeChild,
|
|
238
238
|
fromNode
|
|
239
239
|
);
|
|
@@ -242,7 +242,7 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
|
242
242
|
curFromNodeChild && nextSibling(curFromNodeChild);
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
-
if (!curToNodeChild.
|
|
245
|
+
if (!curToNodeChild.___preserve) {
|
|
246
246
|
morphComponent(component, curToNodeChild);
|
|
247
247
|
}
|
|
248
248
|
}
|
|
@@ -267,8 +267,8 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
|
267
267
|
// up elements
|
|
268
268
|
curToNodeKey = (
|
|
269
269
|
keySequences[referenceComponent.id] || (
|
|
270
|
-
keySequences[referenceComponent.id] = new KeySequence())).
|
|
271
|
-
|
|
270
|
+
keySequences[referenceComponent.id] = new KeySequence())).
|
|
271
|
+
___nextKey(curToNodeKey);
|
|
272
272
|
|
|
273
273
|
if (curFromNodeChild) {
|
|
274
274
|
curFromNodeKey = keysByDOMNode.get(curFromNodeChild);
|
|
@@ -278,12 +278,12 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
|
278
278
|
|
|
279
279
|
if (curFromNodeKey === curToNodeKey) {
|
|
280
280
|
// Elements line up. Now we just have to make sure they are compatible
|
|
281
|
-
if (!curToNodeChild.
|
|
281
|
+
if (!curToNodeChild.___preserve) {
|
|
282
282
|
// We just skip over the fromNode if it is preserved
|
|
283
283
|
|
|
284
284
|
if (
|
|
285
285
|
curVFromNodeChild &&
|
|
286
|
-
curToNodeType === curVFromNodeChild.
|
|
286
|
+
curToNodeType === curVFromNodeChild.___nodeType && (
|
|
287
287
|
curToNodeType !== ELEMENT_NODE ||
|
|
288
288
|
compareNodeNames(curToNodeChild, curVFromNodeChild)))
|
|
289
289
|
{
|
|
@@ -317,7 +317,7 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
|
317
317
|
}
|
|
318
318
|
}
|
|
319
319
|
} else {
|
|
320
|
-
matchingFromEl = referenceComponent.
|
|
320
|
+
matchingFromEl = referenceComponent.___keyedElements[curToNodeKey];
|
|
321
321
|
if (
|
|
322
322
|
matchingFromEl === undefined ||
|
|
323
323
|
matchingFromEl === curFromNodeChild)
|
|
@@ -325,19 +325,19 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
|
325
325
|
if (isHydrate && curFromNodeChild) {
|
|
326
326
|
if (
|
|
327
327
|
curFromNodeChild.nodeType === ELEMENT_NODE && (
|
|
328
|
-
curToNodeChild.
|
|
328
|
+
curToNodeChild.___preserve ||
|
|
329
329
|
caseInsensitiveCompare(
|
|
330
330
|
curFromNodeChild.nodeName,
|
|
331
|
-
curToNodeChild.
|
|
331
|
+
curToNodeChild.___nodeName || ""
|
|
332
332
|
)))
|
|
333
333
|
{
|
|
334
334
|
curVFromNodeChild = virtualizeElement(curFromNodeChild);
|
|
335
|
-
curVFromNodeChild.
|
|
335
|
+
curVFromNodeChild.___nodeName = curToNodeChild.___nodeName;
|
|
336
336
|
keysByDOMNode.set(curFromNodeChild, curToNodeKey);
|
|
337
|
-
referenceComponent.
|
|
337
|
+
referenceComponent.___keyedElements[curToNodeKey] =
|
|
338
338
|
curFromNodeChild;
|
|
339
339
|
|
|
340
|
-
if (curToNodeChild.
|
|
340
|
+
if (curToNodeChild.___preserve) {
|
|
341
341
|
vElementByDOMNode.set(curFromNodeChild, curVFromNodeChild);
|
|
342
342
|
} else {
|
|
343
343
|
morphEl(
|
|
@@ -352,7 +352,7 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
|
352
352
|
curFromNodeChild = fromNextSibling;
|
|
353
353
|
continue;
|
|
354
354
|
} else if (
|
|
355
|
-
curToNodeChild.
|
|
355
|
+
curToNodeChild.___nodeType === FRAGMENT_NODE &&
|
|
356
356
|
curFromNodeChild.nodeType === COMMENT_NODE)
|
|
357
357
|
{
|
|
358
358
|
var content = curFromNodeChild.nodeValue;
|
|
@@ -384,11 +384,11 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
|
384
384
|
);
|
|
385
385
|
keysByDOMNode.set(fragment, curToNodeKey);
|
|
386
386
|
vElementByDOMNode.set(fragment, curToNodeChild);
|
|
387
|
-
referenceComponent.
|
|
387
|
+
referenceComponent.___keyedElements[curToNodeKey] = fragment;
|
|
388
388
|
removeChild(curFromNodeChild);
|
|
389
389
|
removeChild(endNode);
|
|
390
390
|
|
|
391
|
-
if (!curToNodeChild.
|
|
391
|
+
if (!curToNodeChild.___preserve) {
|
|
392
392
|
morphChildren(fragment, curToNodeChild, parentComponent);
|
|
393
393
|
}
|
|
394
394
|
|
|
@@ -413,12 +413,12 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
|
413
413
|
detachedByDOMNode.set(matchingFromEl, undefined);
|
|
414
414
|
}
|
|
415
415
|
|
|
416
|
-
if (!curToNodeChild.
|
|
416
|
+
if (!curToNodeChild.___preserve) {
|
|
417
417
|
curVFromNodeChild = vElementByDOMNode.get(matchingFromEl);
|
|
418
418
|
|
|
419
419
|
if (
|
|
420
420
|
curVFromNodeChild &&
|
|
421
|
-
curToNodeType === curVFromNodeChild.
|
|
421
|
+
curToNodeType === curVFromNodeChild.___nodeType && (
|
|
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.___key === curFromNodeKey)
|
|
440
440
|
{
|
|
441
441
|
// Single element swap
|
|
442
442
|
|
|
@@ -527,7 +527,7 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
|
527
527
|
curFromNodeChild = fromNextSibling;
|
|
528
528
|
|
|
529
529
|
if (
|
|
530
|
-
!globalComponentsContext.
|
|
530
|
+
!globalComponentsContext.___renderedComponentsById[fromComponent.id])
|
|
531
531
|
{
|
|
532
532
|
destroyComponent(fromComponent);
|
|
533
533
|
}
|
|
@@ -549,18 +549,18 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
|
549
549
|
|
|
550
550
|
if (
|
|
551
551
|
caseInsensitiveCompare(
|
|
552
|
-
curVFromNodeChild.
|
|
553
|
-
curToNodeChild.
|
|
552
|
+
curVFromNodeChild.___nodeName,
|
|
553
|
+
curToNodeChild.___nodeName
|
|
554
554
|
))
|
|
555
555
|
{
|
|
556
|
-
curVFromNodeChild.
|
|
556
|
+
curVFromNodeChild.___nodeName = curToNodeChild.___nodeName;
|
|
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.___key) {
|
|
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,18 +587,18 @@ 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.___nodeValue;
|
|
591
591
|
var curFromNodeValue = curFromNodeChild.nodeValue;
|
|
592
592
|
if (curFromNodeValue !== curToNodeValue) {
|
|
593
593
|
if (
|
|
594
594
|
isHydrate &&
|
|
595
595
|
toNextSibling &&
|
|
596
596
|
curFromNodeType === TEXT_NODE &&
|
|
597
|
-
toNextSibling.
|
|
597
|
+
toNextSibling.___nodeType === TEXT_NODE &&
|
|
598
598
|
curFromNodeValue.startsWith(curToNodeValue) &&
|
|
599
599
|
curFromNodeValue.
|
|
600
600
|
slice(curToNodeValue.length).
|
|
601
|
-
startsWith(toNextSibling.
|
|
601
|
+
startsWith(toNextSibling.___nodeValue))
|
|
602
602
|
{
|
|
603
603
|
// In hydrate mode we can use splitText to more efficiently handle
|
|
604
604
|
// adjacent text vdom nodes that were merged.
|
|
@@ -643,10 +643,10 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
|
643
643
|
}
|
|
644
644
|
|
|
645
645
|
// We have processed all of the "to nodes".
|
|
646
|
-
if (fromNode.
|
|
646
|
+
if (fromNode.___finishFragment) {
|
|
647
647
|
// If we are in an unfinished fragment, we have reached the end of the nodes
|
|
648
648
|
// we were matching up and need to end the fragment
|
|
649
|
-
fromNode.
|
|
649
|
+
fromNode.___finishFragment(curFromNodeChild);
|
|
650
650
|
} else {
|
|
651
651
|
// If curFromNodeChild is non-null then we still have some from nodes
|
|
652
652
|
// left over that need to be removed
|
|
@@ -659,7 +659,7 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
|
659
659
|
if (fromComponent = componentByDOMNode.get(curFromNodeChild)) {
|
|
660
660
|
curFromNodeChild = fromNextSibling;
|
|
661
661
|
if (
|
|
662
|
-
!globalComponentsContext.
|
|
662
|
+
!globalComponentsContext.___renderedComponentsById[fromComponent.id])
|
|
663
663
|
{
|
|
664
664
|
destroyComponent(fromComponent);
|
|
665
665
|
}
|
|
@@ -675,7 +675,7 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
|
675
675
|
referenceComponent = parentComponent;
|
|
676
676
|
} else {
|
|
677
677
|
referenceComponent =
|
|
678
|
-
curVFromNodeChild && curVFromNodeChild.
|
|
678
|
+
curVFromNodeChild && curVFromNodeChild.___ownerComponent;
|
|
679
679
|
}
|
|
680
680
|
|
|
681
681
|
detachNode(curFromNodeChild, fromNode, referenceComponent);
|
|
@@ -686,26 +686,26 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
|
686
686
|
}
|
|
687
687
|
|
|
688
688
|
function morphEl(fromEl, vFromEl, toEl, parentComponent) {
|
|
689
|
-
var nodeName = toEl.
|
|
690
|
-
var constId = toEl.
|
|
689
|
+
var nodeName = toEl.___nodeName;
|
|
690
|
+
var constId = toEl.___constId;
|
|
691
691
|
vElementByDOMNode.set(fromEl, toEl);
|
|
692
692
|
|
|
693
|
-
if (constId !== undefined && vFromEl.
|
|
693
|
+
if (constId !== undefined && vFromEl.___constId === constId) {
|
|
694
694
|
return;
|
|
695
695
|
}
|
|
696
696
|
|
|
697
697
|
morphAttrs(fromEl, vFromEl, toEl);
|
|
698
698
|
|
|
699
|
-
if (toEl.
|
|
699
|
+
if (toEl.___preserveBody) {
|
|
700
700
|
return;
|
|
701
701
|
}
|
|
702
702
|
|
|
703
703
|
if (isTextOnly(nodeName)) {
|
|
704
|
-
if (toEl.
|
|
704
|
+
if (toEl.___textContent !== vFromEl.___textContent) {
|
|
705
705
|
if (nodeName === "textarea") {
|
|
706
|
-
fromEl.value = toEl.
|
|
706
|
+
fromEl.value = toEl.___textContent;
|
|
707
707
|
} else {
|
|
708
|
-
fromEl.textContent = toEl.
|
|
708
|
+
fromEl.textContent = toEl.___textContent;
|
|
709
709
|
}
|
|
710
710
|
}
|
|
711
711
|
} else {
|
|
@@ -713,7 +713,7 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
|
713
713
|
}
|
|
714
714
|
} // END: morphEl(...)
|
|
715
715
|
|
|
716
|
-
morphChildren(fromNode, toNode, toNode.
|
|
716
|
+
morphChildren(fromNode, toNode, toNode.___component);
|
|
717
717
|
|
|
718
718
|
detachedNodes.forEach(function (node) {
|
|
719
719
|
var detachedFromComponent = detachedByDOMNode.get(node);
|
|
@@ -730,7 +730,7 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
|
730
730
|
detachedFromComponent !== true && detachedFromComponent
|
|
731
731
|
);
|
|
732
732
|
|
|
733
|
-
if (eventDelegation.
|
|
733
|
+
if (eventDelegation.___handleNodeDetach(node) != false) {
|
|
734
734
|
removeChild(node);
|
|
735
735
|
}
|
|
736
736
|
}
|
|
@@ -12,7 +12,7 @@ var specialHtmlRegexp = /[&<]/;
|
|
|
12
12
|
function virtualizeChildNodes(node, vdomParent, ownerComponent) {
|
|
13
13
|
var curChild = node.firstChild;
|
|
14
14
|
while (curChild) {
|
|
15
|
-
vdomParent.
|
|
15
|
+
vdomParent.___appendChild(virtualize(curChild, ownerComponent));
|
|
16
16
|
curChild = curChild.nextSibling;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -20,7 +20,7 @@ function virtualizeChildNodes(node, vdomParent, ownerComponent) {
|
|
|
20
20
|
function virtualize(node, ownerComponent) {
|
|
21
21
|
switch (node.nodeType) {
|
|
22
22
|
case 1:
|
|
23
|
-
return VElement.
|
|
23
|
+
return VElement.___virtualize(node, virtualizeChildNodes, ownerComponent);
|
|
24
24
|
case 3:
|
|
25
25
|
return new VText(node.nodeValue, ownerComponent);
|
|
26
26
|
case 8:
|
|
@@ -43,7 +43,7 @@ function virtualizeHTML(html, ownerComponent) {
|
|
|
43
43
|
|
|
44
44
|
while (curChild) {
|
|
45
45
|
virtualized = virtualize(curChild, ownerComponent);
|
|
46
|
-
if (virtualized) vdomFragment.
|
|
46
|
+
if (virtualized) vdomFragment.___appendChild(virtualized);
|
|
47
47
|
curChild = curChild.nextSibling;
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -70,19 +70,19 @@ Node_prototype.t = function (value) {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
this.
|
|
74
|
-
return this.
|
|
73
|
+
this.___appendChild(vdomNode || new VText(value.toString()));
|
|
74
|
+
return this.___finishChild();
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
Node_prototype.
|
|
78
|
-
return this.
|
|
77
|
+
Node_prototype.___appendDocumentFragment = function () {
|
|
78
|
+
return this.___appendChild(new VDocumentFragment());
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
-
exports.
|
|
82
|
-
exports.
|
|
83
|
-
exports.
|
|
84
|
-
exports.
|
|
85
|
-
exports.
|
|
86
|
-
exports.
|
|
87
|
-
exports.
|
|
88
|
-
exports.
|
|
81
|
+
exports.___VComment = VComment;
|
|
82
|
+
exports.___VDocumentFragment = VDocumentFragment;
|
|
83
|
+
exports.___VElement = VElement;
|
|
84
|
+
exports.___VText = VText;
|
|
85
|
+
exports.___VComponent = VComponent;
|
|
86
|
+
exports.___VFragment = VFragment;
|
|
87
|
+
exports.___virtualize = virtualize;
|
|
88
|
+
exports.___virtualizeHTML = virtualizeHTML;
|
package/dist/taglib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
// eslint-disable-next-line no-constant-binary-expression
|
|
4
|
-
|
|
4
|
+
let complain = "MARKO_DEBUG" && require("complain");
|
|
5
5
|
const compiler = require("@marko/compiler");
|
|
6
6
|
|
|
7
7
|
function clearCache() {
|
|
@@ -30,13 +30,13 @@ exports.finder = compiler.taglib._finder;
|
|
|
30
30
|
exports.lookup = {
|
|
31
31
|
buildLookup: function (dir, translator) {
|
|
32
32
|
if (!translator || !Array.isArray(translator.taglibs)) {
|
|
33
|
-
translator = require("
|
|
33
|
+
translator = require("../translator");
|
|
34
34
|
// eslint-disable-next-line no-constant-condition
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
if ("MARKO_DEBUG") {
|
|
36
|
+
complain(
|
|
37
|
+
"buildTaglibLookup now requires passing in a transltor as the second argument, eg `buildTaglibLookup(dir, require('marko/translator'))`."
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
return compiler.taglib.buildLookup(dir, translator);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.default = _default;var _indexHtml = _interopRequireDefault(require("./index[html]"));
|
|
2
|
+
var _indexVdom = _interopRequireDefault(require("./index[vdom]"));
|
|
3
|
+
|
|
4
|
+
function _default(path) {
|
|
5
|
+
const {
|
|
6
|
+
hub: {
|
|
7
|
+
file: { markoOpts }
|
|
8
|
+
}
|
|
9
|
+
} = path;
|
|
10
|
+
if (markoOpts.output === "html") {
|
|
11
|
+
(0, _indexHtml.default)(path);
|
|
12
|
+
} else {
|
|
13
|
+
(0, _indexVdom.default)(path);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.default = _default;var _compiler = require("@marko/compiler");
|
|
2
|
+
|
|
3
|
+
var _htmlOutWrite = _interopRequireDefault(require("../util/html-out-write"));
|
|
4
|
+
var _withPreviousLocation = _interopRequireDefault(require("../util/with-previous-location"));
|
|
5
|
+
|
|
6
|
+
function _default(path) {
|
|
7
|
+
const { node } = path;
|
|
8
|
+
|
|
9
|
+
path.replaceWith(
|
|
10
|
+
(0, _withPreviousLocation.default)(
|
|
11
|
+
(0, _htmlOutWrite.default)`<![CDATA[${_compiler.types.stringLiteral(node.value)}]]>`,
|
|
12
|
+
node
|
|
13
|
+
)
|
|
14
|
+
);
|
|
15
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.default = _default;var _compiler = require("@marko/compiler");
|
|
2
|
+
|
|
3
|
+
var _vdomOutWrite = _interopRequireDefault(require("../util/vdom-out-write"));
|
|
4
|
+
var _withPreviousLocation = _interopRequireDefault(require("../util/with-previous-location"));
|
|
5
|
+
|
|
6
|
+
function _default(path) {
|
|
7
|
+
const { node } = path;
|
|
8
|
+
|
|
9
|
+
path.replaceWith(
|
|
10
|
+
(0, _withPreviousLocation.default)((0, _vdomOutWrite.default)("t", _compiler.types.stringLiteral(node.value)), node)
|
|
11
|
+
);
|
|
12
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";exports.__esModule = true;exports.default = _default;var _compiler = require("@marko/compiler");
|
|
2
|
+
|
|
3
|
+
function _default(path) {
|
|
4
|
+
const {
|
|
5
|
+
hub: { file },
|
|
6
|
+
node: {
|
|
7
|
+
body: { body }
|
|
8
|
+
}
|
|
9
|
+
} = path;
|
|
10
|
+
|
|
11
|
+
const classProperties = [];
|
|
12
|
+
let onCreateMethod = body.find(
|
|
13
|
+
(prop) =>
|
|
14
|
+
prop.computed === false &&
|
|
15
|
+
_compiler.types.isIdentifier(prop.key) &&
|
|
16
|
+
prop.key.name === "onCreate"
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const objectProperties = body.
|
|
20
|
+
map((prop) => {
|
|
21
|
+
if (_compiler.types.isClassMethod(prop)) {
|
|
22
|
+
prop.type = "ObjectMethod";
|
|
23
|
+
delete prop.start;
|
|
24
|
+
delete prop.end;
|
|
25
|
+
delete prop.loc;
|
|
26
|
+
return prop;
|
|
27
|
+
} else if (_compiler.types.isClassProperty(prop) && !prop.static) {
|
|
28
|
+
if (!prop.declare) {
|
|
29
|
+
classProperties.push(
|
|
30
|
+
_compiler.types.assignmentExpression(
|
|
31
|
+
"=",
|
|
32
|
+
_compiler.types.memberExpression(_compiler.types.thisExpression(), prop.key, prop.computed),
|
|
33
|
+
prop.value || _compiler.types.unaryExpression("void", _compiler.types.numericLiteral(0))
|
|
34
|
+
)
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
throw file.buildCodeFrameError(
|
|
42
|
+
prop,
|
|
43
|
+
"Unsupported class property on component."
|
|
44
|
+
);
|
|
45
|
+
}).
|
|
46
|
+
filter(Boolean);
|
|
47
|
+
|
|
48
|
+
if (classProperties.length) {
|
|
49
|
+
if (!onCreateMethod) {
|
|
50
|
+
objectProperties.push(
|
|
51
|
+
onCreateMethod = _compiler.types.objectMethod(
|
|
52
|
+
"method",
|
|
53
|
+
_compiler.types.identifier("onCreate"),
|
|
54
|
+
[],
|
|
55
|
+
_compiler.types.blockStatement([])
|
|
56
|
+
)
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
onCreateMethod.body.body.unshift(...classProperties);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
file._inlineComponentClass = _compiler.types.objectExpression(objectProperties);
|
|
64
|
+
path.remove();
|
|
65
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.default = _default;var _indexHtml = _interopRequireDefault(require("./index[html]"));
|
|
2
|
+
var _indexVdom = _interopRequireDefault(require("./index[vdom]"));
|
|
3
|
+
|
|
4
|
+
function _default(path) {
|
|
5
|
+
const {
|
|
6
|
+
hub: {
|
|
7
|
+
file: { markoOpts }
|
|
8
|
+
}
|
|
9
|
+
} = path;
|
|
10
|
+
if (markoOpts.output === "html") {
|
|
11
|
+
(0, _indexHtml.default)(path);
|
|
12
|
+
} else {
|
|
13
|
+
(0, _indexVdom.default)(path);
|
|
14
|
+
}
|
|
15
|
+
}
|