marko 5.29.1 → 5.30.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/bin/markoc.js +18 -18
- package/dist/core-tags/core/await/index.d.marko +10 -0
- package/dist/core-tags/core/await/renderer.js +5 -1
- package/dist/node_modules/@internal/components-beginComponent/index.js +13 -3
- package/dist/node_modules/@internal/components-define-widget-legacy/index-browser.js +331 -0
- package/dist/node_modules/@internal/components-define-widget-legacy/index.js +18 -0
- package/dist/node_modules/@internal/components-define-widget-legacy/package.json +11 -0
- package/dist/node_modules/@internal/components-entry/index-browser.js +2 -2
- package/dist/node_modules/@internal/components-entry/index.js +73 -45
- package/dist/node_modules/@internal/components-entry-legacy/index-browser.js +74 -0
- package/dist/node_modules/@internal/components-entry-legacy/index.js +15 -0
- package/dist/node_modules/@internal/components-entry-legacy/package.json +11 -0
- package/dist/node_modules/@internal/components-registry/index-browser.js +70 -43
- package/dist/node_modules/@internal/components-registry/index.js +2 -2
- package/dist/node_modules/@internal/components-util/index-browser.js +17 -17
- package/dist/node_modules/@internal/components-util/index.js +18 -8
- 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/set-immediate/index-browser.js +1 -1
- package/dist/node_modules/@internal/set-immediate/index-worker.js +2 -2
- package/dist/node_modules/@internal/set-immediate/index.js +2 -2
- package/dist/runtime/RenderResult.js +3 -3
- package/dist/runtime/components/Component.js +146 -148
- package/dist/runtime/components/ComponentDef.js +41 -27
- package/dist/runtime/components/ComponentsContext.js +6 -6
- package/dist/runtime/components/GlobalComponentsContext.js +3 -3
- package/dist/runtime/components/KeySequence.js +3 -3
- package/dist/runtime/components/ServerComponent.js +13 -13
- package/dist/runtime/components/State.js +27 -27
- package/dist/runtime/components/attach-detach.js +7 -7
- 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/browser.json +9 -0
- package/dist/runtime/components/legacy/defineComponent-legacy.js +32 -0
- package/dist/runtime/components/legacy/defineRenderer-legacy.js +171 -0
- package/dist/runtime/components/legacy/defineWidget-legacy.js +1 -0
- package/dist/runtime/components/legacy/dependencies/html.js +3 -0
- package/dist/runtime/components/legacy/dependencies/index.js +178 -0
- package/dist/runtime/components/legacy/dependencies/vdom.js +3 -0
- package/dist/runtime/components/legacy/index.js +1 -0
- package/dist/runtime/components/legacy/jquery.js +51 -0
- package/dist/runtime/components/legacy/ready.js +152 -0
- package/dist/runtime/components/legacy/renderer-legacy.js +230 -0
- package/dist/runtime/components/renderer.js +30 -26
- package/dist/runtime/components/update-manager.js +10 -10
- 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 +7 -9
- package/dist/runtime/helpers/style-value.js +7 -2
- package/dist/runtime/html/AsyncStream.js +20 -20
- package/dist/runtime/html/BufferedWriter.js +2 -2
- package/dist/runtime/html/helpers/_dynamic-attr.js +2 -2
- package/dist/runtime/html/helpers/attr.js +19 -6
- package/dist/runtime/html/helpers/attrs.js +7 -0
- package/dist/runtime/html/helpers/data-marko.js +2 -2
- package/dist/runtime/html/helpers/escape-quotes.js +1 -1
- package/dist/runtime/html/helpers/escape-xml.js +1 -1
- package/dist/runtime/html/helpers/merge-attrs.js +38 -7
- package/dist/runtime/html/index.js +2 -2
- package/dist/runtime/renderable.js +9 -6
- package/dist/runtime/vdom/AsyncVDOMBuilder.js +86 -86
- package/dist/runtime/vdom/VComponent.js +3 -3
- package/dist/runtime/vdom/VDocumentFragment.js +7 -7
- package/dist/runtime/vdom/VElement.js +61 -50
- package/dist/runtime/vdom/VFragment.js +8 -8
- package/dist/runtime/vdom/VNode.js +36 -36
- package/dist/runtime/vdom/VText.js +8 -8
- package/dist/runtime/vdom/helpers/attrs.js +24 -4
- package/dist/runtime/vdom/helpers/merge-attrs.js +16 -0
- package/dist/runtime/vdom/helpers/v-element.js +1 -1
- package/dist/runtime/vdom/helpers/v-text.js +1 -1
- package/dist/runtime/vdom/hot-reload.js +19 -19
- package/dist/runtime/vdom/index.js +2 -2
- package/dist/runtime/vdom/morphdom/fragment.js +5 -5
- package/dist/runtime/vdom/morphdom/helpers.js +5 -5
- package/dist/runtime/vdom/morphdom/index.js +56 -56
- package/dist/runtime/vdom/morphdom/specialElHandlers.js +7 -7
- package/dist/runtime/vdom/preserve-attrs.js +1 -1
- package/dist/runtime/vdom/vdom.js +14 -14
- package/docs/10-awesome-marko-features.md +1 -1
- package/docs/body-content.md +3 -3
- package/docs/class-components.md +6 -6
- package/docs/cloudflare-workers.md +3 -3
- package/docs/compiler.md +5 -5
- package/docs/express.md +2 -2
- package/docs/http.md +1 -1
- package/docs/koa.md +1 -1
- package/docs/lasso.md +1 -1
- package/docs/marko-vs-react.md +2 -2
- package/docs/rendering.md +6 -6
- package/docs/rollup.md +30 -30
- package/docs/troubleshooting-streaming.md +1 -1
- package/docs/typescript.md +1 -1
- package/docs/vite.md +3 -3
- package/docs/webpack.md +25 -25
- package/docs/why-is-marko-fast.md +2 -2
- package/index.d.ts +1 -0
- package/legacy-components-browser.marko +15 -0
- package/legacy-components.js +7 -0
- package/package.json +51 -45
- package/src/compiler/config.js +1 -1
- package/src/compiler/index.js +5 -5
- package/src/core-tags/core/__flush_here_and_after__.js +1 -1
- package/src/core-tags/core/await/AsyncValue.js +1 -1
- package/src/core-tags/core/await/index.d.marko +10 -0
- package/src/core-tags/core/await/renderer.js +8 -4
- package/src/core-tags/core/await/reorderer-renderer.js +1 -1
- package/src/node-require/browser-refresh.js +2 -2
- package/src/node-require/index.js +2 -2
- package/src/node_modules/@internal/components-beginComponent/index.js +16 -6
- package/src/node_modules/@internal/components-define-widget-legacy/index-browser.js +331 -0
- package/src/node_modules/@internal/components-define-widget-legacy/index.js +18 -0
- package/src/node_modules/@internal/components-define-widget-legacy/package.json +11 -0
- package/src/node_modules/@internal/components-entry/index.js +65 -37
- package/src/node_modules/@internal/components-entry-legacy/index-browser.js +74 -0
- package/src/node_modules/@internal/components-entry-legacy/index.js +15 -0
- package/src/node_modules/@internal/components-entry-legacy/package.json +11 -0
- package/src/node_modules/@internal/components-registry/index-browser.js +33 -6
- package/src/node_modules/@internal/components-util/index.js +10 -0
- package/src/runtime/RenderResult.js +3 -3
- package/src/runtime/components/Component.js +16 -18
- package/src/runtime/components/ComponentDef.js +22 -8
- package/src/runtime/components/ComponentsContext.js +1 -1
- package/src/runtime/components/State.js +2 -2
- package/src/runtime/components/attach-detach.js +1 -1
- package/src/runtime/components/dom-data.js +1 -1
- package/src/runtime/components/legacy/browser.json +9 -0
- package/src/runtime/components/legacy/defineComponent-legacy.js +32 -0
- package/src/runtime/components/legacy/defineRenderer-legacy.js +171 -0
- package/src/runtime/components/legacy/defineWidget-legacy.js +1 -0
- package/src/runtime/components/legacy/dependencies/html.js +3 -0
- package/src/runtime/components/legacy/dependencies/index.js +178 -0
- package/src/runtime/components/legacy/dependencies/vdom.js +3 -0
- package/src/runtime/components/legacy/index.js +1 -0
- package/src/runtime/components/legacy/jquery.js +51 -0
- package/src/runtime/components/legacy/ready.js +152 -0
- package/src/runtime/components/legacy/renderer-legacy.js +230 -0
- package/src/runtime/components/renderer.js +4 -0
- package/src/runtime/components/update-manager.js +1 -1
- package/src/runtime/dom-insert.js +1 -1
- package/src/runtime/helpers/dynamic-tag.js +2 -4
- package/src/runtime/helpers/style-value.js +7 -2
- package/src/runtime/html/AsyncStream.js +5 -5
- package/src/runtime/html/BufferedWriter.js +1 -1
- package/src/runtime/html/StringWriter.js +1 -1
- package/src/runtime/html/helpers/attr.js +15 -2
- package/src/runtime/html/helpers/attrs.js +7 -0
- package/src/runtime/html/helpers/merge-attrs.js +38 -7
- package/src/runtime/html/hot-reload.js +1 -1
- package/src/runtime/html/index.js +2 -2
- package/src/runtime/renderable.js +5 -2
- package/src/runtime/vdom/AsyncVDOMBuilder.js +2 -2
- package/src/runtime/vdom/VComponent.js +1 -1
- package/src/runtime/vdom/VDocumentFragment.js +1 -1
- package/src/runtime/vdom/VElement.js +17 -6
- package/src/runtime/vdom/VFragment.js +1 -1
- package/src/runtime/vdom/VNode.js +1 -1
- package/src/runtime/vdom/VText.js +1 -1
- package/src/runtime/vdom/helpers/attrs.js +26 -6
- package/src/runtime/vdom/helpers/merge-attrs.js +16 -0
- package/src/runtime/vdom/hot-reload.js +1 -1
- package/src/runtime/vdom/index.js +2 -2
- package/src/runtime/vdom/morphdom/fragment.js +1 -1
- package/src/runtime/vdom/morphdom/specialElHandlers.js +1 -1
- package/src/taglib/index.js +1 -1
- package/tags-html.d.ts +9 -0
- package/dist/core-tags/core/await/index.marko +0 -13
- package/src/core-tags/core/await/index.marko +0 -13
@@ -0,0 +1,178 @@
|
|
1
|
+
var nodePath = require("path");
|
2
|
+
var defaultResolveFrom = require("resolve-from");
|
3
|
+
var env = process.env.NODE_ENV;
|
4
|
+
var production = !env || env !== "development";
|
5
|
+
|
6
|
+
function getRootDeps(template, context) {
|
7
|
+
if (production && template.___depsArray) {
|
8
|
+
return template.___depsArray;
|
9
|
+
}
|
10
|
+
|
11
|
+
attachDepsAndComponentsToTemplate(template, context);
|
12
|
+
|
13
|
+
var deps = (template.___depsArray = Object.keys(template.___deps).map(
|
14
|
+
(key) => template.___deps[key]
|
15
|
+
));
|
16
|
+
var initModule = getInitModule(template.path, template.___components);
|
17
|
+
|
18
|
+
if (initModule) deps.push(initModule);
|
19
|
+
|
20
|
+
// these dependencies should be last
|
21
|
+
deps.concat = function () {
|
22
|
+
var result = [];
|
23
|
+
result = result.concat.apply(result, arguments);
|
24
|
+
result.push.apply(result, this);
|
25
|
+
return result;
|
26
|
+
};
|
27
|
+
|
28
|
+
return deps;
|
29
|
+
}
|
30
|
+
|
31
|
+
function attachDepsAndComponentsToTemplate(target, context) {
|
32
|
+
var template;
|
33
|
+
|
34
|
+
if (!target.meta && target.template) {
|
35
|
+
template = target.template;
|
36
|
+
} else {
|
37
|
+
template = target;
|
38
|
+
}
|
39
|
+
|
40
|
+
if (typeof template.createOut !== "function") return;
|
41
|
+
if (production && target.___deps) return;
|
42
|
+
|
43
|
+
var deps = (target.___deps = {});
|
44
|
+
var components = (target.___components = {});
|
45
|
+
|
46
|
+
if (!template.meta) {
|
47
|
+
// eslint-disable-next-line no-console
|
48
|
+
console.warn("Metadata not set for template at ", template.path);
|
49
|
+
return;
|
50
|
+
}
|
51
|
+
|
52
|
+
var meta = template.meta;
|
53
|
+
var root = nodePath.dirname(template.path);
|
54
|
+
|
55
|
+
if (meta.deps) {
|
56
|
+
meta.deps.forEach((dep) => {
|
57
|
+
dep = resolveDep(dep, root, context);
|
58
|
+
deps[dep.virtualPath || dep.path] = dep;
|
59
|
+
});
|
60
|
+
}
|
61
|
+
|
62
|
+
if (meta.id && meta.component) {
|
63
|
+
var resolveFrom = (context && context.resolveFrom) || defaultResolveFrom;
|
64
|
+
components[meta.id] = {
|
65
|
+
id: meta.id,
|
66
|
+
path: resolveFrom(root, meta.component),
|
67
|
+
};
|
68
|
+
}
|
69
|
+
|
70
|
+
if (meta.tags) {
|
71
|
+
meta.tags.forEach((tagPath) => {
|
72
|
+
var resolveFrom = context.resolveFrom || defaultResolveFrom;
|
73
|
+
var tag = resolveFrom(root, tagPath);
|
74
|
+
var ext = nodePath.extname(tag);
|
75
|
+
var req = context.require || require;
|
76
|
+
|
77
|
+
try {
|
78
|
+
tag = req.resolve(tag.slice(0, 0 - ext.length) + ".js");
|
79
|
+
} catch (e) {
|
80
|
+
/* ignore error */
|
81
|
+
}
|
82
|
+
|
83
|
+
tag = req(tag);
|
84
|
+
|
85
|
+
attachDepsAndComponentsToTemplate(tag, context);
|
86
|
+
|
87
|
+
if (tag.___deps) Object.assign(deps, tag.___deps);
|
88
|
+
if (tag.___components) Object.assign(components, tag.___components);
|
89
|
+
});
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
function getInitModule(path, components) {
|
94
|
+
var module = null;
|
95
|
+
|
96
|
+
if (components) {
|
97
|
+
components = Object.keys(components).map((key) => components[key]);
|
98
|
+
|
99
|
+
if (components.length) {
|
100
|
+
var root = nodePath.dirname(path);
|
101
|
+
var virtualPath = path + ".init.js";
|
102
|
+
var registrations = components.map(
|
103
|
+
(component) =>
|
104
|
+
`components.register('${component.id}', require('.${
|
105
|
+
nodePath.sep
|
106
|
+
}${nodePath.relative(root, component.path)}'));`
|
107
|
+
);
|
108
|
+
var code = `
|
109
|
+
var components = require('marko/components');
|
110
|
+
${registrations.join("\n")}
|
111
|
+
`;
|
112
|
+
|
113
|
+
module = {
|
114
|
+
type: "require",
|
115
|
+
run: true,
|
116
|
+
virtualModule: {
|
117
|
+
path: virtualPath,
|
118
|
+
read: function (_, callback) {
|
119
|
+
// TODO: Check if read can just return string in lasso 2
|
120
|
+
if (callback) {
|
121
|
+
callback(null, code);
|
122
|
+
} else {
|
123
|
+
return code;
|
124
|
+
}
|
125
|
+
},
|
126
|
+
},
|
127
|
+
};
|
128
|
+
}
|
129
|
+
}
|
130
|
+
|
131
|
+
return module;
|
132
|
+
}
|
133
|
+
|
134
|
+
function resolveDep(dep, root, context) {
|
135
|
+
if (typeof dep === "string") {
|
136
|
+
dep = parseDependencyString(dep);
|
137
|
+
}
|
138
|
+
|
139
|
+
if (dep.path) {
|
140
|
+
var resolveFrom = (context && context.resolveFrom) || defaultResolveFrom;
|
141
|
+
dep.path = resolveFrom(root, dep.path);
|
142
|
+
|
143
|
+
if (dep.path && !dep.type) {
|
144
|
+
dep.type = dep.path.slice(dep.path.lastIndexOf(".") + 1);
|
145
|
+
}
|
146
|
+
}
|
147
|
+
|
148
|
+
if (dep.virtualPath) {
|
149
|
+
dep.virtualPath = nodePath.resolve(root, dep.virtualPath);
|
150
|
+
}
|
151
|
+
|
152
|
+
if (dep.type === "js") {
|
153
|
+
dep.type = "require";
|
154
|
+
dep.run = true;
|
155
|
+
}
|
156
|
+
|
157
|
+
return dep;
|
158
|
+
}
|
159
|
+
|
160
|
+
function parseDependencyString(string) {
|
161
|
+
var match = /^(?:([\w-]+)(?::\s*|\s+))?(.*?(?:\.(\w+))?)$/.exec(string);
|
162
|
+
return {
|
163
|
+
type: match[1] || match[3],
|
164
|
+
path: match[2],
|
165
|
+
};
|
166
|
+
}
|
167
|
+
|
168
|
+
function patch(Template) {
|
169
|
+
Template.prototype.getDependencies = function (context) {
|
170
|
+
context = context || {};
|
171
|
+
|
172
|
+
return getRootDeps(this, context);
|
173
|
+
};
|
174
|
+
}
|
175
|
+
|
176
|
+
exports.getDeps = getRootDeps;
|
177
|
+
exports.resolveDep = resolveDep;
|
178
|
+
exports.patch = patch;
|
@@ -0,0 +1 @@
|
|
1
|
+
module.exports = require("@internal/components-entry-legacy");
|
@@ -0,0 +1,51 @@
|
|
1
|
+
var ready = require("./ready");
|
2
|
+
|
3
|
+
var idRegExp = /^#(\S+)( .*)?/;
|
4
|
+
|
5
|
+
exports.patchComponent = function (jQuery, proto, delayThrow) {
|
6
|
+
if (!(jQuery || (jQuery = window.$)) && !delayThrow) {
|
7
|
+
throw new Error("jQuery not found");
|
8
|
+
}
|
9
|
+
|
10
|
+
(proto || require("../Component").prototype).$ = function jqueryProxy(arg) {
|
11
|
+
var args = arguments;
|
12
|
+
var self = this;
|
13
|
+
|
14
|
+
if (!jQuery) {
|
15
|
+
throw new Error("jQuery not found");
|
16
|
+
}
|
17
|
+
|
18
|
+
if (args.length === 1) {
|
19
|
+
//Handle an "ondomready" callback function
|
20
|
+
if (typeof arg === "function") {
|
21
|
+
return ready(function () {
|
22
|
+
arg.call(self);
|
23
|
+
});
|
24
|
+
} else if (typeof arg === "string") {
|
25
|
+
var match = idRegExp.exec(arg);
|
26
|
+
//Reset the search to 0 so the next call to exec will start from the beginning for the new string
|
27
|
+
if (match != null) {
|
28
|
+
var key = match[1];
|
29
|
+
if (match[2] == null) {
|
30
|
+
return jQuery(self.getEl(key));
|
31
|
+
} else {
|
32
|
+
return jQuery(match[2].trim(), self.getEl(key));
|
33
|
+
}
|
34
|
+
} else {
|
35
|
+
var rootEl = self.getEl();
|
36
|
+
if (!rootEl) {
|
37
|
+
throw new Error("Root element is not defined for component");
|
38
|
+
}
|
39
|
+
if (rootEl) {
|
40
|
+
return jQuery(arg, rootEl);
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
} else if (args.length === 2 && typeof args[1] === "string") {
|
45
|
+
return jQuery(arg, self.getEl(args[1]));
|
46
|
+
} else if (args.length === 0) {
|
47
|
+
return jQuery(self.el);
|
48
|
+
}
|
49
|
+
return jQuery.apply(window, arguments);
|
50
|
+
};
|
51
|
+
};
|
@@ -0,0 +1,152 @@
|
|
1
|
+
/*
|
2
|
+
jQuery's doc.ready/$(function(){}) should
|
3
|
+
you wish to use a cross-browser domReady solution
|
4
|
+
without opting for a library.
|
5
|
+
|
6
|
+
Demo: http://jsfiddle.net/zKLpb/
|
7
|
+
|
8
|
+
usage:
|
9
|
+
$(function(){
|
10
|
+
// your code
|
11
|
+
});
|
12
|
+
|
13
|
+
Parts: jQuery project, Diego Perini, Lucent M.
|
14
|
+
Previous version from Addy Osmani (https://raw.github.com/addyosmani/jquery.parts/master/jquery.documentReady.js)
|
15
|
+
|
16
|
+
This version: Patrick Steele-Idem
|
17
|
+
- Converted to CommonJS module
|
18
|
+
- Code cleanup
|
19
|
+
- Fixes for IE <=10
|
20
|
+
*/
|
21
|
+
|
22
|
+
var isReady = false;
|
23
|
+
var readyBound = false;
|
24
|
+
|
25
|
+
var defaultWindow = typeof window != "undefined" && window;
|
26
|
+
var defaultDocument = typeof document != "undefined" && document;
|
27
|
+
|
28
|
+
var listeners = [];
|
29
|
+
|
30
|
+
function domReadyCallback() {
|
31
|
+
for (var i = 0, len = listeners.length; i < len; i++) {
|
32
|
+
var listener = listeners[i];
|
33
|
+
listener[0].call(listener[1]);
|
34
|
+
}
|
35
|
+
listeners = null;
|
36
|
+
}
|
37
|
+
|
38
|
+
function bindReady(doc) {
|
39
|
+
var toplevel = false;
|
40
|
+
var win = doc.defaultView || defaultWindow || doc;
|
41
|
+
|
42
|
+
// Handle when the DOM is ready
|
43
|
+
function domReady() {
|
44
|
+
// Make sure that the DOM is not already loaded
|
45
|
+
if (!isReady) {
|
46
|
+
// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
|
47
|
+
if (!doc.body) {
|
48
|
+
return setTimeout(domReady, 1);
|
49
|
+
}
|
50
|
+
// Remember that the DOM is ready
|
51
|
+
isReady = true;
|
52
|
+
// If there are functions bound, to execute
|
53
|
+
domReadyCallback();
|
54
|
+
// Execute all of them
|
55
|
+
}
|
56
|
+
} // /ready()
|
57
|
+
|
58
|
+
// The ready event handler
|
59
|
+
function domContentLoaded() {
|
60
|
+
if (doc.addEventListener) {
|
61
|
+
doc.removeEventListener("DOMContentLoaded", domContentLoaded, false);
|
62
|
+
doc.removeEventListener("load", domContentLoaded, false);
|
63
|
+
} else {
|
64
|
+
// we're here because readyState !== "loading" in oldIE
|
65
|
+
// which is good enough for us to call the dom ready!
|
66
|
+
doc.detachEvent("onreadystatechange", domContentLoaded);
|
67
|
+
doc.detachEvent("onload", domContentLoaded);
|
68
|
+
}
|
69
|
+
domReady();
|
70
|
+
}
|
71
|
+
|
72
|
+
// The DOM ready check for Internet Explorer
|
73
|
+
function doScrollCheck() {
|
74
|
+
if (isReady) {
|
75
|
+
return;
|
76
|
+
}
|
77
|
+
|
78
|
+
try {
|
79
|
+
// If IE is used, use the trick by Diego Perini
|
80
|
+
// http://javascript.nwbox.com/IEContentLoaded/
|
81
|
+
doc.documentElement.doScroll("left");
|
82
|
+
} catch (error) {
|
83
|
+
setTimeout(doScrollCheck, 1);
|
84
|
+
return;
|
85
|
+
}
|
86
|
+
// and execute any waiting functions
|
87
|
+
domReady();
|
88
|
+
}
|
89
|
+
|
90
|
+
// Catch cases where $ is called after the
|
91
|
+
// browser event has already occurred. IE <= 10 has a bug that results in 'interactive' being assigned
|
92
|
+
// to the readyState before the DOM is really ready
|
93
|
+
if (
|
94
|
+
document.attachEvent
|
95
|
+
? document.readyState === "complete"
|
96
|
+
: document.readyState !== "loading"
|
97
|
+
) {
|
98
|
+
// We will get here if the browser is IE and the readyState === 'complete' or the browser
|
99
|
+
// is not IE and the readyState === 'interactive' || 'complete'
|
100
|
+
domReady(doc);
|
101
|
+
} else if (doc.addEventListener) {
|
102
|
+
// Standards-based browsers support DOMContentLoaded
|
103
|
+
// Use the handy event callback
|
104
|
+
doc.addEventListener("DOMContentLoaded", domContentLoaded, false);
|
105
|
+
// A fallback to win.onload, that will always work
|
106
|
+
win.addEventListener("load", domContentLoaded, false);
|
107
|
+
// If IE event model is used
|
108
|
+
} else if (doc.attachEvent) {
|
109
|
+
// ensure firing before onload,
|
110
|
+
// maybe late but safe also for iframes
|
111
|
+
doc.attachEvent("onreadystatechange", domContentLoaded);
|
112
|
+
// A fallback to win.onload, that will always work
|
113
|
+
win.attachEvent("onload", domContentLoaded);
|
114
|
+
// If IE and not a frame
|
115
|
+
// continually check to see if the document is ready
|
116
|
+
try {
|
117
|
+
toplevel = win.frameElement == null;
|
118
|
+
} catch (e) {
|
119
|
+
/* ignore error */
|
120
|
+
}
|
121
|
+
if (doc.documentElement.doScroll && toplevel) {
|
122
|
+
doScrollCheck();
|
123
|
+
}
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
function ready(callback, thisObj, doc) {
|
128
|
+
if (isReady) {
|
129
|
+
return callback.call(thisObj);
|
130
|
+
}
|
131
|
+
|
132
|
+
listeners.push([callback, thisObj]);
|
133
|
+
|
134
|
+
if (!readyBound) {
|
135
|
+
readyBound = true;
|
136
|
+
bindReady(doc || defaultDocument);
|
137
|
+
}
|
138
|
+
}
|
139
|
+
|
140
|
+
module.exports = ready;
|
141
|
+
|
142
|
+
module.exports.patchComponent = function (proto) {
|
143
|
+
if (proto && proto.ready) {
|
144
|
+
// Don't patch if the component has overwritten the ready method.
|
145
|
+
return;
|
146
|
+
}
|
147
|
+
|
148
|
+
(proto || require("../Component").prototype).ready = function (callback) {
|
149
|
+
var document = this.el.ownerDocument;
|
150
|
+
ready(callback, this, document);
|
151
|
+
};
|
152
|
+
};
|
@@ -0,0 +1,230 @@
|
|
1
|
+
var getComponentsContext =
|
2
|
+
require("../ComponentsContext").___getComponentsContext;
|
3
|
+
var componentsUtil = require("@internal/components-util");
|
4
|
+
var componentLookup = componentsUtil.___componentLookup;
|
5
|
+
var registry = require("@internal/components-registry");
|
6
|
+
var modernRenderer = require("../renderer");
|
7
|
+
var resolveComponentKey = modernRenderer.___resolveComponentKey;
|
8
|
+
var trackAsyncComponents = modernRenderer.___trackAsyncComponents;
|
9
|
+
var beginComponent = require("@internal/components-beginComponent");
|
10
|
+
var endComponent = require("@internal/components-endComponent");
|
11
|
+
var complain = "MARKO_DEBUG" && require("complain");
|
12
|
+
|
13
|
+
function createRendererFunc(templateRenderFunc, componentProps) {
|
14
|
+
var typeName = componentProps.t;
|
15
|
+
//var assignedId = componentProps.id;
|
16
|
+
var isSplit = componentProps.s === true;
|
17
|
+
var isImplicit = componentProps.i === true;
|
18
|
+
|
19
|
+
return function renderer(input, out, assignedId, renderingLogic) {
|
20
|
+
trackAsyncComponents(out);
|
21
|
+
|
22
|
+
var componentsContext = getComponentsContext(out);
|
23
|
+
var parentLegacyComponentDef = componentsContext.___legacyComponentDef;
|
24
|
+
|
25
|
+
if (isImplicit && parentLegacyComponentDef) {
|
26
|
+
templateRenderFunc(
|
27
|
+
input,
|
28
|
+
out,
|
29
|
+
parentLegacyComponentDef,
|
30
|
+
parentLegacyComponentDef.___component,
|
31
|
+
parentLegacyComponentDef.___component.___rawState,
|
32
|
+
out.global
|
33
|
+
);
|
34
|
+
return;
|
35
|
+
}
|
36
|
+
|
37
|
+
var widgetBody = input.renderBody;
|
38
|
+
var widgetState = input.widgetState;
|
39
|
+
var widgetConfig = input.widgetConfig;
|
40
|
+
var globalComponentsContext = componentsContext.___globalContext;
|
41
|
+
var component = globalComponentsContext.___rerenderComponent;
|
42
|
+
|
43
|
+
var isRerender = component !== undefined;
|
44
|
+
var id = assignedId;
|
45
|
+
var isExisting;
|
46
|
+
var parentComponentDef = componentsContext.___componentDef;
|
47
|
+
var ownerComponentDef = out.___assignedComponentDef;
|
48
|
+
var ownerComponentId = ownerComponentDef && ownerComponentDef.id;
|
49
|
+
var key = out.___assignedKey;
|
50
|
+
var customEvents = out.___assignedCustomEvents;
|
51
|
+
|
52
|
+
out.___assignedComponentDef = null;
|
53
|
+
|
54
|
+
if (component) {
|
55
|
+
id = component.id;
|
56
|
+
isExisting = true;
|
57
|
+
globalComponentsContext.___rerenderComponent = null;
|
58
|
+
} else {
|
59
|
+
if (key != null) {
|
60
|
+
id = id || resolveComponentKey(key.toString(), parentComponentDef);
|
61
|
+
} else if (parentComponentDef) {
|
62
|
+
id = parentComponentDef.___nextComponentId();
|
63
|
+
} else {
|
64
|
+
id = globalComponentsContext.___nextComponentId();
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
if (registry.___isServer && typeName) {
|
69
|
+
if (renderingLogic) delete renderingLogic.onRender;
|
70
|
+
component = registry.___createComponent(
|
71
|
+
renderingLogic,
|
72
|
+
id,
|
73
|
+
input,
|
74
|
+
out,
|
75
|
+
typeName,
|
76
|
+
customEvents,
|
77
|
+
ownerComponentId
|
78
|
+
);
|
79
|
+
if (isSplit || widgetState) {
|
80
|
+
component.input = null;
|
81
|
+
} else if (input.widgetProps) {
|
82
|
+
// eslint-disable-next-line no-constant-condition
|
83
|
+
if ("MARKO_DEBUG") {
|
84
|
+
complain(
|
85
|
+
"Possible performance impact: this widget does not contain state, but is marked as a stateful widget. This will result in additional hydration data serialized. In order for marko to identify this as a split widget, w-bind should use a widget.js with defineWidget rather than index.js with defineComponent.",
|
86
|
+
{ location: typeName, level: 1 }
|
87
|
+
);
|
88
|
+
}
|
89
|
+
component.input = input.widgetProps;
|
90
|
+
}
|
91
|
+
} else {
|
92
|
+
if (!component) {
|
93
|
+
if (isRerender) {
|
94
|
+
// Look in in the DOM to see if a component with the same ID and type already exists.
|
95
|
+
component = componentLookup[id];
|
96
|
+
if (component && component.___type !== typeName) {
|
97
|
+
component = undefined;
|
98
|
+
}
|
99
|
+
}
|
100
|
+
|
101
|
+
if (component) {
|
102
|
+
isExisting = true;
|
103
|
+
} else {
|
104
|
+
isExisting = false;
|
105
|
+
// We need to create a new instance of the component
|
106
|
+
if (typeName) {
|
107
|
+
component = registry.___createComponent(typeName, id);
|
108
|
+
}
|
109
|
+
}
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
113
|
+
var isFakeComponent = false;
|
114
|
+
|
115
|
+
if (!component) {
|
116
|
+
isFakeComponent = true;
|
117
|
+
component = {
|
118
|
+
id: id,
|
119
|
+
___keyedElements: {},
|
120
|
+
};
|
121
|
+
} else {
|
122
|
+
component.___updateQueued = true;
|
123
|
+
|
124
|
+
if (widgetState) {
|
125
|
+
component.state = widgetState;
|
126
|
+
}
|
127
|
+
}
|
128
|
+
|
129
|
+
component.widgetConfig = widgetConfig;
|
130
|
+
component.___widgetBody = widgetBody || component.___widgetBody;
|
131
|
+
|
132
|
+
var componentDef = beginComponent(
|
133
|
+
componentsContext,
|
134
|
+
component,
|
135
|
+
key,
|
136
|
+
ownerComponentDef,
|
137
|
+
isSplit,
|
138
|
+
isFakeComponent
|
139
|
+
);
|
140
|
+
componentsContext.___legacyComponentDef = componentDef;
|
141
|
+
|
142
|
+
// This is a hack, but we have to swap out the component instance stored with this node
|
143
|
+
var vComponentNode = out.___parent;
|
144
|
+
|
145
|
+
componentDef.___component = isFakeComponent ? null : component;
|
146
|
+
componentDef.___isExisting = isExisting;
|
147
|
+
componentDef.___isLegacy = true;
|
148
|
+
|
149
|
+
componentDef.t = function (typeName) {
|
150
|
+
if (typeName) {
|
151
|
+
if (registry.___isServer) {
|
152
|
+
var oldComponent = component;
|
153
|
+
if (renderingLogic) delete renderingLogic.onRender;
|
154
|
+
component = registry.___createComponent(
|
155
|
+
renderingLogic || {},
|
156
|
+
id,
|
157
|
+
input,
|
158
|
+
out,
|
159
|
+
typeName,
|
160
|
+
customEvents,
|
161
|
+
ownerComponentId
|
162
|
+
);
|
163
|
+
if (isSplit || widgetState) {
|
164
|
+
component.input = null;
|
165
|
+
} else if (input.widgetProps) {
|
166
|
+
// eslint-disable-next-line no-constant-condition
|
167
|
+
if ("MARKO_DEBUG") {
|
168
|
+
complain(
|
169
|
+
"Possible performance impact: this widget does not contain state, but is marked as a stateful widget. This will result in additional hydration data serialized. In order for marko to identify this as a split widget, w-bind should use a widget.js with defineWidget rather than index.js with defineComponent.",
|
170
|
+
{ location: typeName, level: 1 }
|
171
|
+
);
|
172
|
+
}
|
173
|
+
component.input = input.widgetProps;
|
174
|
+
}
|
175
|
+
Object.assign(component, oldComponent);
|
176
|
+
beginComponent(
|
177
|
+
componentsContext,
|
178
|
+
component,
|
179
|
+
key,
|
180
|
+
ownerComponentDef,
|
181
|
+
isSplit,
|
182
|
+
false,
|
183
|
+
this
|
184
|
+
);
|
185
|
+
} else {
|
186
|
+
vComponentNode.___component = component = registry.___createComponent(
|
187
|
+
typeName,
|
188
|
+
component.id
|
189
|
+
);
|
190
|
+
}
|
191
|
+
this.___component = component;
|
192
|
+
}
|
193
|
+
|
194
|
+
return component;
|
195
|
+
};
|
196
|
+
|
197
|
+
if (!registry.___isServer) {
|
198
|
+
component.___legacyRender && component.___legacyRender();
|
199
|
+
}
|
200
|
+
|
201
|
+
// Render the template associated with the component using the final template
|
202
|
+
// data that we constructed
|
203
|
+
templateRenderFunc(
|
204
|
+
input,
|
205
|
+
out,
|
206
|
+
componentDef,
|
207
|
+
component,
|
208
|
+
component.___rawState,
|
209
|
+
out.global
|
210
|
+
);
|
211
|
+
|
212
|
+
if (customEvents && componentDef.___component) {
|
213
|
+
if (registry.___isServer) {
|
214
|
+
componentDef.___customEvents = customEvents;
|
215
|
+
componentDef.___scope = ownerComponentId;
|
216
|
+
} else {
|
217
|
+
componentDef.___component.___setCustomEvents(
|
218
|
+
customEvents,
|
219
|
+
ownerComponentId
|
220
|
+
);
|
221
|
+
}
|
222
|
+
}
|
223
|
+
|
224
|
+
endComponent(out, componentDef);
|
225
|
+
componentsContext.___componentDef = parentComponentDef;
|
226
|
+
componentsContext.___legacyComponentDef = parentLegacyComponentDef;
|
227
|
+
};
|
228
|
+
}
|
229
|
+
|
230
|
+
module.exports = createRendererFunc;
|
@@ -230,3 +230,7 @@ function createRendererFunc(
|
|
230
230
|
}
|
231
231
|
|
232
232
|
module.exports = createRendererFunc;
|
233
|
+
|
234
|
+
// exports used by the legacy renderer
|
235
|
+
createRendererFunc.___resolveComponentKey = resolveComponentKey;
|
236
|
+
createRendererFunc.___trackAsyncComponents = trackAsyncComponents;
|
@@ -67,13 +67,11 @@ module.exports = function dynamicTag(
|
|
67
67
|
|
68
68
|
var renderer =
|
69
69
|
tag._ ||
|
70
|
-
tag.
|
71
|
-
(tag.renderer && tag.renderer.renderer) ||
|
72
|
-
tag.renderer;
|
70
|
+
(tag.renderer ? tag.renderer.renderer || tag.renderer : tag.render);
|
73
71
|
|
74
72
|
// eslint-disable-next-line no-constant-condition
|
75
73
|
if ("MARKO_DEBUG") {
|
76
|
-
if (tag.renderer && tag.renderer.renderer
|
74
|
+
if (tag.renderer && tag.renderer.renderer) {
|
77
75
|
complain(
|
78
76
|
"An object with a 'renderer' was passed to the dynamic tag, but renderer was another template."
|
79
77
|
);
|
@@ -14,11 +14,15 @@ module.exports = function styleHelper(style) {
|
|
14
14
|
|
15
15
|
if (type !== "string") {
|
16
16
|
var styles = "";
|
17
|
+
var sep = "";
|
17
18
|
|
18
19
|
if (Array.isArray(style)) {
|
19
20
|
for (var i = 0, len = style.length; i < len; i++) {
|
20
21
|
var next = styleHelper(style[i]);
|
21
|
-
if (next)
|
22
|
+
if (next) {
|
23
|
+
styles += sep + next;
|
24
|
+
sep = ";";
|
25
|
+
}
|
22
26
|
}
|
23
27
|
} else if (type === "object") {
|
24
28
|
for (var name in style) {
|
@@ -28,7 +32,8 @@ module.exports = function styleHelper(style) {
|
|
28
32
|
value += "px";
|
29
33
|
}
|
30
34
|
|
31
|
-
styles += changeCase.___camelToDashCase(name) + ":" + value
|
35
|
+
styles += sep + changeCase.___camelToDashCase(name) + ":" + value;
|
36
|
+
sep = ";";
|
32
37
|
}
|
33
38
|
}
|
34
39
|
}
|