marko 4.26.3 → 4.27.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 +15 -15
- package/dist/compiler/ast/CustomTag.js +2 -2
- package/dist/core-tags/components/TransformHelper/handleLegacyBind.js +0 -4
- package/dist/core-tags/core/await/renderer.js +0 -4
- package/dist/core-tags/migrate/all-tags/body-only-if.js +0 -1
- package/dist/core-tags/migrate/all-tags/control-flow-directives.js +0 -1
- package/dist/core-tags/migrate/all-tags/dynamic-attributes.js +1 -2
- package/dist/core-tags/migrate/all-tags/include-directive.js +0 -2
- package/dist/core-tags/migrate/all-tags/legacy-nested-tag.js +0 -2
- package/dist/core-tags/migrate/all-tags/marko-init.js +0 -2
- package/dist/core-tags/migrate/all-tags/modifier-key.js +0 -2
- package/dist/core-tags/migrate/all-tags/ref.js +1 -3
- package/dist/core-tags/migrate/all-tags/w-bind.js +0 -2
- package/dist/core-tags/migrate/all-tags/w-body.js +0 -2
- package/dist/core-tags/migrate/all-tags/w-config.js +0 -2
- package/dist/core-tags/migrate/all-tags/w-for.js +0 -3
- package/dist/core-tags/migrate/all-tags/w-id.js +1 -4
- package/dist/core-tags/migrate/all-tags/w-on.js +1 -4
- package/dist/core-tags/migrate/all-tags/w-preserve-attrs.js +0 -2
- package/dist/core-tags/migrate/all-tags/w-preserve.js +1 -3
- package/dist/core-tags/migrate/all-tags/widget-in-attrs.js +2 -11
- package/dist/core-tags/migrate/all-templates/non-standard-template-literals.js +0 -4
- package/dist/core-tags/migrate/all-templates/render-calls.js +0 -2
- package/dist/core-tags/migrate/assign-tag.js +0 -2
- package/dist/core-tags/migrate/async-fragment-tag.js +0 -2
- package/dist/core-tags/migrate/async-fragments-tag.js +0 -2
- package/dist/core-tags/migrate/await-tag.js +0 -7
- package/dist/core-tags/migrate/class-tag.js +0 -2
- package/dist/core-tags/migrate/component-globals-tag.js +0 -2
- package/dist/core-tags/migrate/for-tag.js +0 -2
- package/dist/core-tags/migrate/include-tag.js +0 -1
- package/dist/core-tags/migrate/invoke-tag.js +0 -2
- package/dist/core-tags/migrate/layout-placeholder-tag.js +0 -1
- package/dist/core-tags/migrate/layout-put-tag.js +0 -1
- package/dist/core-tags/migrate/layout-use-tag.js +0 -1
- package/dist/core-tags/migrate/macro-body-tag.js +0 -2
- package/dist/core-tags/migrate/macro-tag.js +0 -2
- package/dist/core-tags/migrate/unless-tag.js +0 -1
- package/dist/core-tags/migrate/var-tag.js +0 -2
- package/dist/node_modules/@internal/components-define-widget-legacy/index-browser.js +0 -10
- package/dist/node_modules/@internal/components-entry-legacy/index-browser.js +0 -4
- package/dist/runtime/RenderResult.js +0 -3
- package/dist/runtime/components/Component.js +0 -6
- package/dist/runtime/components/ComponentDef.js +0 -3
- package/dist/runtime/components/ServerComponent.js +0 -4
- package/dist/runtime/components/legacy/defineComponent-legacy.js +0 -3
- package/dist/runtime/components/legacy/defineRenderer-legacy.js +1 -6
- package/dist/runtime/components/legacy/index.js +3 -1
- package/dist/runtime/helpers/for-of.js +3 -1
- package/dist/runtime/html/helpers/attr.js +0 -4
- package/dist/runtime/html/helpers/attrs.js +0 -2
- package/dist/runtime/html/helpers/merge-attrs.js +0 -3
- package/dist/runtime/vdom/VElement.js +0 -3
- package/dist/runtime/vdom/helpers/attrs.js +0 -2
- package/dist/taglib/taglib-loader/loadTagFromProps.js +15 -0
- 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/express.md +1 -1
- package/docs/fastify.md +4 -4
- package/docs/hapi.md +3 -3
- package/docs/http.md +1 -1
- package/docs/huncwot.md +1 -1
- package/docs/installing.md +2 -2
- package/docs/koa.md +2 -2
- package/docs/lasso.md +1 -1
- package/docs/marko-4-upgrade.md +1 -1
- package/docs/marko-v4.md +4 -4
- package/docs/marko-vs-react.md +2 -2
- package/docs/rendering.md +6 -6
- package/docs/server-side-rendering.md +3 -3
- package/docs/webpack.md +16 -16
- package/docs/why-is-marko-fast.md +3 -3
- package/package.json +1 -1
- package/src/compiler/Builder.js +13 -13
- package/src/compiler/CodeGenerator.js +2 -2
- package/src/compiler/CodeWriter.js +1 -1
- package/src/compiler/CompileContext.js +30 -30
- package/src/compiler/Compiler.js +3 -3
- package/src/compiler/HtmlJsParser.js +4 -4
- package/src/compiler/Migrator.js +2 -2
- package/src/compiler/Normalizer.js +5 -5
- package/src/compiler/Parser.js +11 -11
- package/src/compiler/Walker.js +1 -1
- package/src/compiler/ast/ArrayExpression.js +1 -1
- package/src/compiler/ast/BinaryExpression.js +1 -1
- package/src/compiler/ast/ConditionalExpression.js +1 -1
- package/src/compiler/ast/CustomTag.js +14 -14
- package/src/compiler/ast/Declaration.js +2 -2
- package/src/compiler/ast/DocumentType.js +2 -2
- package/src/compiler/ast/ForEach.js +1 -1
- package/src/compiler/ast/ForEachProp.js +1 -1
- package/src/compiler/ast/ForRange.js +1 -1
- package/src/compiler/ast/HtmlAttribute/html/generateCode.js +4 -4
- package/src/compiler/ast/HtmlAttribute/vdom/generateCode.js +2 -2
- package/src/compiler/ast/HtmlAttributeCollection.js +3 -3
- package/src/compiler/ast/HtmlComment.js +1 -1
- package/src/compiler/ast/HtmlElement/html/EndTag.js +1 -1
- package/src/compiler/ast/HtmlElement/html/StartTag.js +3 -3
- package/src/compiler/ast/HtmlElement/html/generateCode.js +5 -5
- package/src/compiler/ast/HtmlElement/index.js +1 -1
- package/src/compiler/ast/HtmlElement/vdom/HtmlElementVDOM.js +1 -1
- package/src/compiler/ast/HtmlElement/vdom/generateCode.js +3 -3
- package/src/compiler/ast/If.js +1 -1
- package/src/compiler/ast/LogicalExpression.js +1 -1
- package/src/compiler/ast/MemberExpression.js +1 -1
- package/src/compiler/ast/NewExpression.js +1 -1
- package/src/compiler/ast/Node.js +4 -4
- package/src/compiler/ast/ObjectExpression.js +2 -2
- package/src/compiler/ast/Property.js +1 -1
- package/src/compiler/ast/SequenceExpression.js +1 -1
- package/src/compiler/ast/TemplateLiteral.js +1 -1
- package/src/compiler/ast/TemplateRoot.js +3 -3
- package/src/compiler/ast/Text/index.js +1 -1
- package/src/compiler/ast/UnaryExpression.js +1 -1
- package/src/compiler/ast/UpdateExpression.js +1 -1
- package/src/compiler/config.js +1 -1
- package/src/compiler/index.js +5 -5
- package/src/compiler/modules.js +2 -2
- package/src/compiler/util/UniqueVars.js +4 -4
- package/src/compiler/util/convertRawJavaScriptAst.js +1 -1
- package/src/compiler/util/javaScriptReservedWords.js +1 -1
- package/src/compiler/util/macros.js +1 -1
- package/src/compiler/util/mergeProps.js +3 -3
- package/src/compiler/util/parseJavaScriptArgs.js +1 -1
- package/src/compiler/util/parseJavaScriptParams.js +1 -1
- package/src/compiler/util/parseRawJavaScriptAst.js +1 -1
- package/src/compiler/util/removeComments.js +6 -6
- package/src/compiler/util/tokenizer.js +3 -3
- package/src/compiler/util/vdom/VDOMOptimizer.js +2 -2
- package/src/core-tags/cache/cached-fragment-tag.js +2 -2
- package/src/core-tags/cache/default-cache-manager.js +2 -2
- package/src/core-tags/components/TransformHelper/ComponentArgsCompiler.js +3 -3
- package/src/core-tags/components/TransformHelper/assignComponentId.js +3 -3
- package/src/core-tags/components/TransformHelper/convertToComponent.js +4 -4
- package/src/core-tags/components/TransformHelper/getComponentFiles.js +1 -1
- package/src/core-tags/components/TransformHelper/handleComponentEvents.js +3 -3
- package/src/core-tags/components/TransformHelper/handleComponentPreserve.js +7 -7
- package/src/core-tags/components/TransformHelper/handleLegacyBind.js +2 -8
- package/src/core-tags/components/TransformHelper/handleRootNodes.js +14 -14
- package/src/core-tags/components/TransformHelper/handleScopedAttrs.js +1 -1
- package/src/core-tags/components/TransformHelper/index.js +1 -1
- package/src/core-tags/components/component-tag.js +1 -1
- package/src/core-tags/components/components-transformer.js +2 -2
- package/src/core-tags/components/util/generateRegisterComponentCode.js +2 -2
- package/src/core-tags/components/widget-types-tag.js +2 -2
- package/src/core-tags/core/await/AsyncValue.js +1 -1
- package/src/core-tags/core/await/renderer.js +3 -12
- package/src/core-tags/core/await/reorderer-renderer.js +1 -1
- package/src/core-tags/core/core-transformer.js +5 -5
- package/src/core-tags/core/html-comment-tag.js +1 -1
- package/src/core-tags/core/import-tag.js +1 -1
- package/src/core-tags/core/util/parseImport.js +8 -8
- package/src/core-tags/html/normalize-script-text.js +1 -1
- package/src/core-tags/migrate/all-tags/body-only-if.js +4 -5
- package/src/core-tags/migrate/all-tags/control-flow-directives.js +2 -5
- package/src/core-tags/migrate/all-tags/dynamic-attributes.js +1 -4
- package/src/core-tags/migrate/all-tags/include-directive.js +0 -4
- package/src/core-tags/migrate/all-tags/index.js +2 -2
- package/src/core-tags/migrate/all-tags/legacy-nested-tag.js +0 -5
- package/src/core-tags/migrate/all-tags/marko-init.js +2 -8
- package/src/core-tags/migrate/all-tags/modifier-key.js +1 -7
- package/src/core-tags/migrate/all-tags/params.js +1 -1
- package/src/core-tags/migrate/all-tags/ref.js +1 -5
- package/src/core-tags/migrate/all-tags/w-bind.js +8 -12
- package/src/core-tags/migrate/all-tags/w-body.js +3 -7
- package/src/core-tags/migrate/all-tags/w-config.js +1 -5
- package/src/core-tags/migrate/all-tags/w-for.js +1 -8
- package/src/core-tags/migrate/all-tags/w-id.js +1 -8
- package/src/core-tags/migrate/all-tags/w-on.js +2 -9
- package/src/core-tags/migrate/all-tags/w-preserve-attrs.js +1 -5
- package/src/core-tags/migrate/all-tags/w-preserve.js +3 -7
- package/src/core-tags/migrate/all-tags/widget-in-attrs.js +4 -17
- package/src/core-tags/migrate/all-templates/index.js +2 -2
- package/src/core-tags/migrate/all-templates/non-standard-template-literals.js +6 -12
- package/src/core-tags/migrate/all-templates/render-calls.js +4 -8
- package/src/core-tags/migrate/all-templates/widget-data-is-state.js +2 -2
- package/src/core-tags/migrate/all-templates/widget-get-template-data.js +2 -2
- package/src/core-tags/migrate/assign-tag.js +2 -6
- package/src/core-tags/migrate/async-fragment-tag.js +2 -6
- package/src/core-tags/migrate/async-fragments-tag.js +0 -4
- package/src/core-tags/migrate/await-tag.js +8 -23
- package/src/core-tags/migrate/class-tag.js +0 -4
- package/src/core-tags/migrate/component-globals-tag.js +0 -4
- package/src/core-tags/migrate/for-tag.js +12 -16
- package/src/core-tags/migrate/include-tag.js +2 -5
- package/src/core-tags/migrate/invoke-tag.js +2 -6
- package/src/core-tags/migrate/layout-placeholder-tag.js +0 -3
- package/src/core-tags/migrate/layout-put-tag.js +0 -3
- package/src/core-tags/migrate/layout-use-tag.js +0 -3
- package/src/core-tags/migrate/macro-body-tag.js +0 -5
- package/src/core-tags/migrate/macro-tag.js +5 -10
- package/src/core-tags/migrate/unless-tag.js +0 -3
- package/src/core-tags/migrate/util/addIdScopedAttr.js +1 -1
- package/src/core-tags/migrate/util/import-tag.js +6 -6
- package/src/core-tags/migrate/util/parseFor.js +20 -20
- package/src/core-tags/migrate/util/renderCallToDynamicTag.js +7 -7
- package/src/core-tags/migrate/var-tag.js +4 -8
- package/src/express.js +1 -1
- package/src/hot-reload.js +3 -3
- package/src/node-require/index.js +1 -1
- package/src/node_modules/@internal/components-define-widget-legacy/index-browser.js +4 -55
- package/src/node_modules/@internal/components-entry-legacy/index-browser.js +0 -10
- package/src/runtime/RenderResult.js +3 -16
- package/src/runtime/components/Component.js +2 -23
- package/src/runtime/components/ComponentDef.js +2 -8
- package/src/runtime/components/ComponentsContext.js +1 -1
- package/src/runtime/components/ServerComponent.js +0 -6
- 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/defineComponent-legacy.js +0 -5
- package/src/runtime/components/legacy/defineRenderer-legacy.js +1 -16
- package/src/runtime/components/legacy/dependencies/index.js +10 -10
- package/src/runtime/components/legacy/index.js +5 -0
- package/src/runtime/components/legacy/renderer-legacy.js +1 -1
- package/src/runtime/components/update-manager.js +1 -1
- package/src/runtime/dom-insert.js +1 -1
- package/src/runtime/helpers/_weak-map.js +1 -1
- package/src/runtime/helpers/bind-component.js +1 -1
- package/src/runtime/helpers/for-of.js +1 -6
- 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 +0 -9
- package/src/runtime/html/helpers/attrs.js +0 -6
- package/src/runtime/html/helpers/merge-attrs.js +0 -8
- package/src/runtime/html/index.js +1 -1
- package/src/runtime/renderable.js +1 -1
- package/src/runtime/vdom/AsyncVDOMBuilder.js +2 -2
- package/src/runtime/vdom/VComment.js +1 -1
- package/src/runtime/vdom/VComponent.js +1 -1
- package/src/runtime/vdom/VDocumentFragment.js +1 -1
- package/src/runtime/vdom/VElement.js +4 -11
- 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 +0 -7
- package/src/runtime/vdom/index.js +1 -1
- package/src/runtime/vdom/morphdom/fragment.js +1 -1
- package/src/runtime/vdom/morphdom/specialElHandlers.js +1 -1
- package/src/taglib/taglib-finder/index.js +5 -5
- package/src/taglib/taglib-loader/Tag.js +8 -8
- package/src/taglib/taglib-loader/Taglib.js +1 -1
- package/src/taglib/taglib-loader/loadAttributeFromProps.js +1 -1
- package/src/taglib/taglib-loader/loadTagFromProps.js +29 -14
- package/src/taglib/taglib-loader/loadTaglibFromProps.js +9 -9
- package/src/taglib/taglib-loader/scanTagsDir.js +6 -6
- package/src/taglib/taglib-lookup/TaglibLookup.js +8 -8
@@ -24,7 +24,7 @@ module.exports = function merge(props1, props2, context) {
|
|
24
24
|
let mergeVar = context.helper("merge");
|
25
25
|
argProp.value = context.builder.functionCall(mergeVar, [
|
26
26
|
props2, // Input props from the attributes take precedence
|
27
|
-
argProp.value
|
27
|
+
argProp.value,
|
28
28
|
]);
|
29
29
|
|
30
30
|
return props1;
|
@@ -38,14 +38,14 @@ module.exports = function merge(props1, props2, context) {
|
|
38
38
|
|
39
39
|
return context.builder.functionCall(mergeVar, [
|
40
40
|
props2, // Input props from the attributes take precedence
|
41
|
-
props1
|
41
|
+
props1,
|
42
42
|
]);
|
43
43
|
}
|
44
44
|
} else {
|
45
45
|
let mergeVar = context.helper("merge");
|
46
46
|
return context.builder.functionCall(mergeVar, [
|
47
47
|
props2, // Input props from the attributes take precedence
|
48
|
-
props1
|
48
|
+
props1,
|
49
49
|
]);
|
50
50
|
}
|
51
51
|
};
|
@@ -11,7 +11,7 @@ function parseJavaScriptArgs(args, builder) {
|
|
11
11
|
const ast = parseRawJavaScriptAst`_(${args})`;
|
12
12
|
|
13
13
|
return ast.body[0].expression.arguments.map(
|
14
|
-
node =>
|
14
|
+
(node) =>
|
15
15
|
convertRawJavaScriptAst(node, builder) ||
|
16
16
|
builder.expression(ast.source.slice(node.range[0], node.range[1]), ast)
|
17
17
|
);
|
@@ -9,7 +9,7 @@ function parseJavaScriptParams(params, builder) {
|
|
9
9
|
|
10
10
|
const ast = parseRawJavaScriptAst`(${params}) => {}`;
|
11
11
|
|
12
|
-
return ast.body[0].expression.params.map(node => {
|
12
|
+
return ast.body[0].expression.params.map((node) => {
|
13
13
|
const paramSrc = ast.source.slice(node.range[0], node.range[1]);
|
14
14
|
return node.type === "Identifier"
|
15
15
|
? builder.identifier(paramSrc)
|
@@ -2,26 +2,26 @@
|
|
2
2
|
var tokenizer = require("./tokenizer").create([
|
3
3
|
{
|
4
4
|
name: "stringDouble",
|
5
|
-
pattern: /"(?:[^"]|\\")*"
|
5
|
+
pattern: /"(?:[^"]|\\")*"/,
|
6
6
|
},
|
7
7
|
{
|
8
8
|
name: "stringSingle",
|
9
|
-
pattern: /'(?:[^']|\\')*'
|
9
|
+
pattern: /'(?:[^']|\\')*'/,
|
10
10
|
},
|
11
11
|
{
|
12
12
|
name: "singleLineComment",
|
13
|
-
pattern:
|
13
|
+
pattern: /\/\/.*/,
|
14
14
|
},
|
15
15
|
{
|
16
16
|
name: "multiLineComment",
|
17
|
-
pattern: /\/\*(?:[\s\S]*?)
|
18
|
-
}
|
17
|
+
pattern: /\/\*(?:[\s\S]*?)\*\//,
|
18
|
+
},
|
19
19
|
]);
|
20
20
|
|
21
21
|
module.exports = function removeComments(str) {
|
22
22
|
var comments = [];
|
23
23
|
|
24
|
-
tokenizer.forEachToken(str, token => {
|
24
|
+
tokenizer.forEachToken(str, (token) => {
|
25
25
|
switch (token.name) {
|
26
26
|
case "singleLineComment":
|
27
27
|
case "multiLineComment":
|
@@ -10,7 +10,7 @@ function create(tokens) {
|
|
10
10
|
start: matches.index,
|
11
11
|
end: matches.index + matches[0].length,
|
12
12
|
name: tokenDef.name,
|
13
|
-
value: tokenValue
|
13
|
+
value: tokenValue,
|
14
14
|
};
|
15
15
|
}
|
16
16
|
}
|
@@ -18,7 +18,7 @@ function create(tokens) {
|
|
18
18
|
|
19
19
|
var tokensRegExp = new RegExp(
|
20
20
|
tokens
|
21
|
-
.map(token => {
|
21
|
+
.map((token) => {
|
22
22
|
return "(" + token.pattern.source + ")";
|
23
23
|
})
|
24
24
|
.join("|"),
|
@@ -33,7 +33,7 @@ function create(tokens) {
|
|
33
33
|
let token = getToken(matches);
|
34
34
|
callback(token);
|
35
35
|
}
|
36
|
-
}
|
36
|
+
},
|
37
37
|
};
|
38
38
|
}
|
39
39
|
|
@@ -27,7 +27,7 @@ const OPTIMIZER_CONTEXT_KEY = Symbol();
|
|
27
27
|
const OPTIONS_DEFAULT = { optimizeTextNodes: true, optimizeStaticNodes: true };
|
28
28
|
const OPTIONS_OPTIMIZE_TEXT_NODES = {
|
29
29
|
optimizeTextNodes: true,
|
30
|
-
optimizeStaticNodes: false
|
30
|
+
optimizeStaticNodes: false,
|
31
31
|
};
|
32
32
|
|
33
33
|
class OptimizerContext {
|
@@ -159,7 +159,7 @@ function doOptimizeNode(node, context, options) {
|
|
159
159
|
let walker = context.createWalker({
|
160
160
|
enterArray(nodes) {
|
161
161
|
return generateNodesForArray(nodes, context, options);
|
162
|
-
}
|
162
|
+
},
|
163
163
|
});
|
164
164
|
|
165
165
|
return walker.walk(node);
|
@@ -24,14 +24,14 @@ function createCache() {
|
|
24
24
|
|
25
25
|
callback(null, value);
|
26
26
|
});
|
27
|
-
}
|
27
|
+
},
|
28
28
|
};
|
29
29
|
}
|
30
30
|
|
31
31
|
var defaultCacheManager = {
|
32
32
|
getCache: function (cacheName) {
|
33
33
|
return caches[cacheName] || (caches[cacheName] = createCache());
|
34
|
-
}
|
34
|
+
},
|
35
35
|
};
|
36
36
|
|
37
37
|
module.exports = defaultCacheManager;
|
@@ -37,7 +37,7 @@ class ComponentArgs {
|
|
37
37
|
options.eventType,
|
38
38
|
options.targetMethod,
|
39
39
|
options.isOnce,
|
40
|
-
options.extraArgs
|
40
|
+
options.extraArgs,
|
41
41
|
]);
|
42
42
|
}
|
43
43
|
|
@@ -66,7 +66,7 @@ class ComponentArgs {
|
|
66
66
|
return codegen.builder.functionCall(tagVar, tagArgs);
|
67
67
|
};
|
68
68
|
} else {
|
69
|
-
el.onBeforeGenerateCode(event => {
|
69
|
+
el.onBeforeGenerateCode((event) => {
|
70
70
|
let funcTarget = builder.memberExpression(
|
71
71
|
builder.identifierOut(),
|
72
72
|
builder.identifier("c")
|
@@ -76,7 +76,7 @@ class ComponentArgs {
|
|
76
76
|
event.insertCode(builder.functionCall(funcTarget, funcArgs));
|
77
77
|
});
|
78
78
|
|
79
|
-
el.onAfterGenerateCode(event => {
|
79
|
+
el.onAfterGenerateCode((event) => {
|
80
80
|
let funcTarget = builder.memberExpression(
|
81
81
|
builder.identifierOut(),
|
82
82
|
builder.identifier("c")
|
@@ -99,7 +99,7 @@ module.exports = function assignComponentId(isRepeated) {
|
|
99
99
|
|
100
100
|
this.componentIdInfo = {
|
101
101
|
idExpression: idExpression,
|
102
|
-
nestedIdExpression: nestedIdExpression
|
102
|
+
nestedIdExpression: nestedIdExpression,
|
103
103
|
};
|
104
104
|
|
105
105
|
return this.componentIdInfo;
|
@@ -188,7 +188,7 @@ const createIndexKey = (forNode, transformHelper) => {
|
|
188
188
|
|
189
189
|
const forASTNodes = ["ForEach", "ForEachProp", "ForRange", "ForStatement"];
|
190
190
|
|
191
|
-
const getParentFor = el => {
|
191
|
+
const getParentFor = (el) => {
|
192
192
|
let current = el;
|
193
193
|
while ((current = current.parentNode) && current.type !== "Macro") {
|
194
194
|
if (current.tagName === "for" || forASTNodes.includes(current.type)) {
|
@@ -197,7 +197,7 @@ const getParentFor = el => {
|
|
197
197
|
}
|
198
198
|
};
|
199
199
|
|
200
|
-
const getFirstElementChild = el => {
|
200
|
+
const getFirstElementChild = (el) => {
|
201
201
|
let current = el.firstChild;
|
202
202
|
while (
|
203
203
|
current &&
|
@@ -101,7 +101,7 @@ module.exports = function handleComponentBind(options) {
|
|
101
101
|
|
102
102
|
// TODO Deprecation warning for inner binds
|
103
103
|
let componentNode = context.createNodeForEl("_component", {
|
104
|
-
props: builder.literal(componentProps)
|
104
|
+
props: builder.literal(componentProps),
|
105
105
|
});
|
106
106
|
el.wrapWith(componentNode);
|
107
107
|
return;
|
@@ -146,7 +146,7 @@ module.exports = function handleComponentBind(options) {
|
|
146
146
|
eventArgs.node.addRenderFunctionParam(builder.identifier("state"));
|
147
147
|
}
|
148
148
|
|
149
|
-
eventArgs.node.generateAssignRenderCode = eventArgs => {
|
149
|
+
eventArgs.node.generateAssignRenderCode = (eventArgs) => {
|
150
150
|
const nodes = [];
|
151
151
|
const templateVar = eventArgs.templateVar;
|
152
152
|
const templateRendererMember = eventArgs.templateRendererMember;
|
@@ -154,7 +154,7 @@ module.exports = function handleComponentBind(options) {
|
|
154
154
|
|
155
155
|
const createRendererArgs = [
|
156
156
|
renderFunctionVar,
|
157
|
-
builder.literal(componentProps)
|
157
|
+
builder.literal(componentProps),
|
158
158
|
];
|
159
159
|
|
160
160
|
if (markoComponentVar) {
|
@@ -177,7 +177,7 @@ module.exports = function handleComponentBind(options) {
|
|
177
177
|
),
|
178
178
|
builder.functionCall(defineComponentHelper, [
|
179
179
|
markoComponentVar || builder.literal({}),
|
180
|
-
templateRendererMember
|
180
|
+
templateRendererMember,
|
181
181
|
])
|
182
182
|
)
|
183
183
|
);
|
@@ -83,7 +83,7 @@ module.exports = function handleComponentEvents() {
|
|
83
83
|
if (hasComponentEvents) {
|
84
84
|
var attrs = el.getAttributes().concat([]);
|
85
85
|
|
86
|
-
attrs.forEach(attr => {
|
86
|
+
attrs.forEach((attr) => {
|
87
87
|
var eventType;
|
88
88
|
var targetMethod;
|
89
89
|
var attrName = attr.name;
|
@@ -150,7 +150,7 @@ module.exports = function handleComponentEvents() {
|
|
150
150
|
eventType,
|
151
151
|
targetMethod,
|
152
152
|
extraArgs,
|
153
|
-
isOnce
|
153
|
+
isOnce,
|
154
154
|
});
|
155
155
|
} else {
|
156
156
|
// We are adding an event listener for a DOM event (not a custom event)
|
@@ -171,7 +171,7 @@ module.exports = function handleComponentEvents() {
|
|
171
171
|
eventType,
|
172
172
|
targetMethod,
|
173
173
|
extraArgs,
|
174
|
-
isOnce
|
174
|
+
isOnce,
|
175
175
|
});
|
176
176
|
}
|
177
177
|
});
|
@@ -7,7 +7,7 @@ function addPreserve(transformHelper, bodyOnly, condition) {
|
|
7
7
|
var isCustomTag = el.type !== "HtmlElement";
|
8
8
|
|
9
9
|
if (bodyOnly) {
|
10
|
-
el.forEachChild(child => {
|
10
|
+
el.forEachChild((child) => {
|
11
11
|
child._canBePreserved = true;
|
12
12
|
});
|
13
13
|
} else {
|
@@ -15,7 +15,7 @@ function addPreserve(transformHelper, bodyOnly, condition) {
|
|
15
15
|
}
|
16
16
|
|
17
17
|
var preserveAttrs = {
|
18
|
-
key: transformHelper.assignComponentId().nestedIdExpression
|
18
|
+
key: transformHelper.assignComponentId().nestedIdExpression,
|
19
19
|
};
|
20
20
|
|
21
21
|
if (isCustomTag) {
|
@@ -100,20 +100,20 @@ const preserveTypes = [
|
|
100
100
|
// The new preserve types
|
101
101
|
{
|
102
102
|
attribute: "no-update",
|
103
|
-
handler: preserveHandler
|
103
|
+
handler: preserveHandler,
|
104
104
|
},
|
105
105
|
{
|
106
106
|
attribute: "no-update-if",
|
107
|
-
handler: preserveIfHandler
|
107
|
+
handler: preserveIfHandler,
|
108
108
|
},
|
109
109
|
{
|
110
110
|
attribute: "no-update-body",
|
111
|
-
handler: preserveBodyHandler
|
111
|
+
handler: preserveBodyHandler,
|
112
112
|
},
|
113
113
|
{
|
114
114
|
attribute: "no-update-body-if",
|
115
|
-
handler: preserveBodyIfHandler
|
116
|
-
}
|
115
|
+
handler: preserveBodyIfHandler,
|
116
|
+
},
|
117
117
|
];
|
118
118
|
|
119
119
|
module.exports = function handleComponentPreserve() {
|
@@ -35,12 +35,6 @@ module.exports = function handleLegacyBind() {
|
|
35
35
|
|
36
36
|
const hasWidgetTypes = context.isFlagSet("hasWidgetTypes");
|
37
37
|
|
38
|
-
if (hasWidgetTypes) {
|
39
|
-
context.deprecate(
|
40
|
-
"The <widget-types> tag is deprecated. Please remove it. See: https://github.com/marko-js/marko/issues/514"
|
41
|
-
);
|
42
|
-
}
|
43
|
-
|
44
38
|
if (bindAttrValue != null && !bindAttr.isLiteralValue()) {
|
45
39
|
// This is a dynamic expression. The <widget-types> should have been found.
|
46
40
|
if (!hasWidgetTypes) {
|
@@ -61,7 +55,7 @@ module.exports = function handleLegacyBind() {
|
|
61
55
|
builder.identifier("marko_componentTypes"),
|
62
56
|
bindAttrValue,
|
63
57
|
true /* computed */
|
64
|
-
)
|
58
|
+
),
|
65
59
|
]
|
66
60
|
)
|
67
61
|
);
|
@@ -84,6 +78,6 @@ module.exports = function handleLegacyBind() {
|
|
84
78
|
componentModule,
|
85
79
|
rendererModule,
|
86
80
|
isLegacyComponent: true,
|
87
|
-
rootNodes: [el]
|
81
|
+
rootNodes: [el],
|
88
82
|
});
|
89
83
|
};
|
@@ -8,7 +8,7 @@ const escodegen = require("escodegen");
|
|
8
8
|
const FLAG_COMPONENT_STYLE = Symbol("COMPONENT_STYLE");
|
9
9
|
const espreeOptions = {
|
10
10
|
sourceType: "script",
|
11
|
-
ecmaVersion: espree.latestEcmaVersion
|
11
|
+
ecmaVersion: espree.latestEcmaVersion,
|
12
12
|
};
|
13
13
|
|
14
14
|
function handleStyleElement(styleEl, transformHelper) {
|
@@ -62,7 +62,7 @@ function handleStyleElement(styleEl, transformHelper) {
|
|
62
62
|
type: lang,
|
63
63
|
code: styleCode,
|
64
64
|
virtualPath: "./" + path.basename(context.filename) + "." + lang,
|
65
|
-
path: "./" + path.basename(context.filename)
|
65
|
+
path: "./" + path.basename(context.filename),
|
66
66
|
});
|
67
67
|
}
|
68
68
|
|
@@ -77,14 +77,14 @@ function methodToProperty(method) {
|
|
77
77
|
value: method.value,
|
78
78
|
kind: "init",
|
79
79
|
method: false,
|
80
|
-
shorthand: false
|
80
|
+
shorthand: false,
|
81
81
|
};
|
82
82
|
}
|
83
83
|
|
84
84
|
function classToObject(cls, el, transformHelper) {
|
85
85
|
return {
|
86
86
|
type: "ObjectExpression",
|
87
|
-
properties: cls.body.body.map(method => {
|
87
|
+
properties: cls.body.body.map((method) => {
|
88
88
|
if (method.type != "MethodDefinition") {
|
89
89
|
throw Error(
|
90
90
|
"Only methods are allowed on single file component class definitions."
|
@@ -104,7 +104,7 @@ function classToObject(cls, el, transformHelper) {
|
|
104
104
|
} else {
|
105
105
|
return method;
|
106
106
|
}
|
107
|
-
})
|
107
|
+
}),
|
108
108
|
};
|
109
109
|
}
|
110
110
|
|
@@ -123,7 +123,7 @@ function handleClassDeclaration(classEl, transformHelper) {
|
|
123
123
|
if (errorIndex != null && errorIndex >= 0) {
|
124
124
|
transformHelper.context.addError({
|
125
125
|
pos: classEl.pos + errorIndex,
|
126
|
-
message: message
|
126
|
+
message: message,
|
127
127
|
});
|
128
128
|
return;
|
129
129
|
}
|
@@ -151,7 +151,7 @@ function handleClassDeclaration(classEl, transformHelper) {
|
|
151
151
|
let moduleInfo = {
|
152
152
|
inlineId: componentVar,
|
153
153
|
filename: transformHelper.filename,
|
154
|
-
requirePath: "./" + path.basename(transformHelper.filename)
|
154
|
+
requirePath: "./" + path.basename(transformHelper.filename),
|
155
155
|
};
|
156
156
|
|
157
157
|
classEl.detach();
|
@@ -179,7 +179,7 @@ module.exports = function handleRootNodes() {
|
|
179
179
|
context.addDependency("package: ./" + componentFiles.package);
|
180
180
|
}
|
181
181
|
|
182
|
-
componentFiles.styles.forEach(styleFile => {
|
182
|
+
componentFiles.styles.forEach((styleFile) => {
|
183
183
|
context.addDependency("./" + styleFile);
|
184
184
|
});
|
185
185
|
|
@@ -188,7 +188,7 @@ module.exports = function handleRootNodes() {
|
|
188
188
|
|
189
189
|
let moduleInfo = {
|
190
190
|
filename: path.join(dirname, file),
|
191
|
-
requirePath: "./" + file.slice(0, file.lastIndexOf("."))
|
191
|
+
requirePath: "./" + file.slice(0, file.lastIndexOf(".")),
|
192
192
|
};
|
193
193
|
|
194
194
|
componentModule = rendererModule = moduleInfo;
|
@@ -199,7 +199,7 @@ module.exports = function handleRootNodes() {
|
|
199
199
|
|
200
200
|
componentModule = {
|
201
201
|
filename: path.join(dirname, file),
|
202
|
-
requirePath: "./" + file.slice(0, file.lastIndexOf("."))
|
202
|
+
requirePath: "./" + file.slice(0, file.lastIndexOf(".")),
|
203
203
|
};
|
204
204
|
}
|
205
205
|
|
@@ -264,7 +264,7 @@ module.exports = function handleRootNodes() {
|
|
264
264
|
walker.skip();
|
265
265
|
return;
|
266
266
|
}
|
267
|
-
}
|
267
|
+
},
|
268
268
|
});
|
269
269
|
|
270
270
|
walker.walk(templateRoot);
|
@@ -281,7 +281,7 @@ module.exports = function handleRootNodes() {
|
|
281
281
|
|
282
282
|
// After normalizing the text nodes to remove whitespace we may have detached
|
283
283
|
// some of the root text nodes so remove those from our list
|
284
|
-
rootNodes = rootNodes.filter(rootNode => {
|
284
|
+
rootNodes = rootNodes.filter((rootNode) => {
|
285
285
|
return rootNode.isDetached() !== true;
|
286
286
|
});
|
287
287
|
|
@@ -296,7 +296,7 @@ module.exports = function handleRootNodes() {
|
|
296
296
|
|
297
297
|
componentModule = rendererModule = {
|
298
298
|
filename: this.filename,
|
299
|
-
requirePath: "./" + path.basename(this.filename)
|
299
|
+
requirePath: "./" + path.basename(this.filename),
|
300
300
|
};
|
301
301
|
}
|
302
302
|
|
@@ -305,6 +305,6 @@ module.exports = function handleRootNodes() {
|
|
305
305
|
isImplicitComponent,
|
306
306
|
rootNodes,
|
307
307
|
componentModule,
|
308
|
-
rendererModule
|
308
|
+
rendererModule,
|
309
309
|
});
|
310
310
|
};
|
@@ -8,7 +8,7 @@ module.exports = function codeGenerator(el, codegen) {
|
|
8
8
|
var bodyFunc = builder.renderBodyFunction(el.body, [
|
9
9
|
builder.identifierOut(),
|
10
10
|
builder.identifier("__component"),
|
11
|
-
builder.identifier("state")
|
11
|
+
builder.identifier("state"),
|
12
12
|
]);
|
13
13
|
|
14
14
|
var componentProps = el.getAttributeValue("props");
|
@@ -24,10 +24,10 @@ module.exports = function transform(el, context) {
|
|
24
24
|
el.prependChild(
|
25
25
|
builder.vars({
|
26
26
|
widget: builder.functionCall(getWidgetFromOut, [
|
27
|
-
builder.identifier("out")
|
27
|
+
builder.identifier("out"),
|
28
28
|
]),
|
29
29
|
__component: builder.identifier("widget"),
|
30
|
-
component: builder.memberExpression("__component", "_c")
|
30
|
+
component: builder.memberExpression("__component", "_c"),
|
31
31
|
})
|
32
32
|
);
|
33
33
|
}
|
@@ -73,14 +73,14 @@ function generateRegisterComponentCode(
|
|
73
73
|
builder.identifier("module"),
|
74
74
|
builder.identifier("exports")
|
75
75
|
)
|
76
|
-
)
|
76
|
+
),
|
77
77
|
]
|
78
78
|
);
|
79
79
|
}
|
80
80
|
|
81
81
|
registerNode = builder.functionCall(registerComponent, [
|
82
82
|
builder.literal(componentId),
|
83
|
-
def
|
83
|
+
def,
|
84
84
|
]);
|
85
85
|
} else {
|
86
86
|
registerNode = builder.literal(componentId);
|
@@ -16,7 +16,7 @@ module.exports = function codeGenerator(el, codegen) {
|
|
16
16
|
|
17
17
|
var typesObject = {};
|
18
18
|
|
19
|
-
attrs.forEach(attr => {
|
19
|
+
attrs.forEach((attr) => {
|
20
20
|
if (!attr.isLiteralString()) {
|
21
21
|
codegen.addError("Component type should be a string");
|
22
22
|
return;
|
@@ -40,7 +40,7 @@ module.exports = function codeGenerator(el, codegen) {
|
|
40
40
|
let componentModule = {
|
41
41
|
legacy: true,
|
42
42
|
filename: filename,
|
43
|
-
requirePath: requirePath
|
43
|
+
requirePath: requirePath,
|
44
44
|
};
|
45
45
|
|
46
46
|
typesObject[attr.name] = generateRegisterComponentCode(
|
@@ -1,5 +1,4 @@
|
|
1
1
|
"use strict";
|
2
|
-
var complain = "MARKO_DEBUG" && require("complain");
|
3
2
|
var AsyncValue = require("./AsyncValue");
|
4
3
|
|
5
4
|
function safeRenderBody(renderBody, targetOut, data) {
|
@@ -14,14 +13,6 @@ function requestData(provider, timeout) {
|
|
14
13
|
var asyncValue = new AsyncValue();
|
15
14
|
|
16
15
|
if (typeof provider === "function") {
|
17
|
-
// eslint-disable-next-line no-constant-condition
|
18
|
-
if ("MARKO_DEBUG") {
|
19
|
-
complain(
|
20
|
-
"Passing a callback function to the <await> tag has been deprecated, please use a promise instead.",
|
21
|
-
{ level: 1, locationIndex: 3 }
|
22
|
-
);
|
23
|
-
}
|
24
|
-
|
25
16
|
var callback = function (err, data) {
|
26
17
|
if (err) {
|
27
18
|
asyncValue.___reject(err);
|
@@ -102,7 +93,7 @@ module.exports = function awaitTag(input, out) {
|
|
102
93
|
var awaitInfo = {
|
103
94
|
name: name,
|
104
95
|
clientReorder: clientReorder,
|
105
|
-
dataProvider: provider
|
96
|
+
dataProvider: provider,
|
106
97
|
};
|
107
98
|
|
108
99
|
if (clientReorder) {
|
@@ -112,7 +103,7 @@ module.exports = function awaitTag(input, out) {
|
|
112
103
|
out.global.___clientReorderContext ||
|
113
104
|
(out.global.___clientReorderContext = {
|
114
105
|
instances: [],
|
115
|
-
nextId: 0
|
106
|
+
nextId: 0,
|
116
107
|
});
|
117
108
|
|
118
109
|
var id = (awaitInfo.id = input.name || clientReorderContext.nextId++);
|
@@ -159,7 +150,7 @@ module.exports = function awaitTag(input, out) {
|
|
159
150
|
out.flush(); // Flush everything up to this await instance
|
160
151
|
asyncOut = awaitInfo.out = out.beginAsync({
|
161
152
|
timeout: 0, // We will use our code for controlling timeout
|
162
|
-
name: name
|
153
|
+
name: name,
|
163
154
|
});
|
164
155
|
}
|
165
156
|
|