marko 4.26.5 → 4.28.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +2510 -0
- package/README.md +1 -1
- package/bin/markoc.js +15 -15
- package/dist/compiler/CompileContext.js +1 -0
- package/dist/compiler/ast/CustomTag.js +2 -2
- package/dist/core-tags/components/TransformHelper/convertToComponent.js +1 -1
- 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/node_modules/@internal/components-registry/index-browser.js +2 -0
- 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 +0 -6
- package/dist/runtime/components/legacy/index.js +3 -1
- package/dist/runtime/helpers/dynamic-tag.js +3 -0
- package/dist/runtime/helpers/for-of.js +3 -1
- package/dist/runtime/helpers/interop-require.js +3 -0
- 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-finder/index.js +1 -1
- package/dist/taglib/taglib-loader/Taglib.js +2 -1
- package/dist/taglib/taglib-loader/index.js +2 -2
- package/dist/taglib/taglib-loader/loadTagFromProps.js +15 -0
- package/dist/taglib/taglib-loader/loadTaglibFromFile.js +2 -2
- package/dist/taglib/taglib-loader/loadTaglibFromProps.js +12 -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 -2
- 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 +31 -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 +7 -5
- 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 +2 -53
- package/src/node_modules/@internal/components-entry-legacy/index-browser.js +0 -10
- package/src/node_modules/@internal/components-registry/index-browser.js +2 -0
- 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 +0 -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/dynamic-tag.js +3 -0
- package/src/runtime/helpers/for-of.js +1 -6
- package/src/runtime/helpers/interop-require.js +3 -0
- 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 +6 -6
- package/src/taglib/taglib-loader/Tag.js +8 -8
- package/src/taglib/taglib-loader/Taglib.js +3 -2
- package/src/taglib/taglib-loader/index.js +2 -2
- package/src/taglib/taglib-loader/loadAttributeFromProps.js +1 -1
- package/src/taglib/taglib-loader/loadTagFromProps.js +29 -14
- package/src/taglib/taglib-loader/loadTaglibFromFile.js +2 -2
- package/src/taglib/taglib-loader/loadTaglibFromProps.js +27 -9
- package/src/taglib/taglib-loader/scanTagsDir.js +6 -6
- package/src/taglib/taglib-lookup/TaglibLookup.js +8 -8
@@ -2,20 +2,16 @@ const newTags = {
|
|
2
2
|
"w-preserve": "no-update",
|
3
3
|
"w-preserve-if": "no-update-if",
|
4
4
|
"w-preserve-body": "no-update-body",
|
5
|
-
"w-preserve-body-if": "no-update-body-if"
|
5
|
+
"w-preserve-body-if": "no-update-body-if",
|
6
6
|
};
|
7
|
-
module.exports = function migrate(el
|
8
|
-
el.forEachAttribute(attr => {
|
7
|
+
module.exports = function migrate(el) {
|
8
|
+
el.forEachAttribute((attr) => {
|
9
9
|
const name = attr.name;
|
10
10
|
if (!name || !Object.keys(newTags).includes(name)) {
|
11
11
|
return;
|
12
12
|
}
|
13
13
|
|
14
14
|
const newAttrName = newTags[name];
|
15
|
-
context.deprecate(
|
16
|
-
`The "${name}" attribute is deprecated. Please use "${newAttrName}" attribute instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-w‐*-Attributes`
|
17
|
-
);
|
18
|
-
|
19
15
|
attr.name = newAttrName;
|
20
16
|
});
|
21
17
|
};
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module.exports = function migrate(el, context) {
|
2
|
-
el.forEachAttribute(attr => {
|
2
|
+
el.forEachAttribute((attr) => {
|
3
3
|
const value = attr.value;
|
4
4
|
|
5
5
|
if (
|
@@ -7,31 +7,18 @@ module.exports = function migrate(el, context) {
|
|
7
7
|
el.tagName !== "var" &&
|
8
8
|
el.tagName !== "assign"
|
9
9
|
) {
|
10
|
-
context.deprecate(
|
11
|
-
`The "*=widget.elId("someId")" is deprecated. Please use "*:scoped="someId"" modifier instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-w‐*-Attributes`
|
12
|
-
);
|
13
|
-
|
14
10
|
attr.name += ":scoped";
|
15
11
|
attr.value = value.args[0];
|
16
12
|
return;
|
17
13
|
}
|
18
14
|
|
19
|
-
|
20
|
-
const walker = context.createWalker({
|
15
|
+
context.createWalker({
|
21
16
|
enter(node) {
|
22
17
|
if (isWidgetMemberExpression(node)) {
|
23
18
|
node.object.name = "component";
|
24
|
-
found = true;
|
25
19
|
}
|
26
|
-
}
|
27
|
-
});
|
28
|
-
walker.walk(value);
|
29
|
-
|
30
|
-
if (found) {
|
31
|
-
context.deprecate(
|
32
|
-
`The "widget" variable is deprecated. Please use "component" instead.`
|
33
|
-
);
|
34
|
-
}
|
20
|
+
},
|
21
|
+
}).walk(value);
|
35
22
|
});
|
36
23
|
};
|
37
24
|
|
@@ -2,10 +2,10 @@ const commonMigrators = [
|
|
2
2
|
require("./non-standard-template-literals"),
|
3
3
|
require("./render-calls"),
|
4
4
|
require("./widget-data-is-state"),
|
5
|
-
require("./widget-get-template-data")
|
5
|
+
require("./widget-get-template-data"),
|
6
6
|
];
|
7
7
|
|
8
8
|
module.exports = function (root, context) {
|
9
|
-
commonMigrators.forEach(migrator => migrator(root, context));
|
9
|
+
commonMigrators.forEach((migrator) => migrator(root, context));
|
10
10
|
return true;
|
11
11
|
};
|
@@ -16,7 +16,7 @@ module.exports = function migrator(el, context) {
|
|
16
16
|
} else {
|
17
17
|
// For others we keep track of them to run an optional migration below.
|
18
18
|
node._originalExpressions = node.expressions;
|
19
|
-
node.expressions = node.expressions.map(expr =>
|
19
|
+
node.expressions = node.expressions.map((expr) =>
|
20
20
|
builder.conditionalExpression(
|
21
21
|
builder.binaryExpression(expr, "==", builder.literalNull()),
|
22
22
|
builder.literal(""),
|
@@ -26,17 +26,11 @@ module.exports = function migrator(el, context) {
|
|
26
26
|
literals.push(node);
|
27
27
|
}
|
28
28
|
}
|
29
|
-
}
|
29
|
+
},
|
30
30
|
});
|
31
31
|
|
32
32
|
walker.walk(el);
|
33
33
|
|
34
|
-
if (found) {
|
35
|
-
context.deprecate(
|
36
|
-
"Non standard template literals have been deprecated, please use javascript template literals instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-nonstandard-template-literals"
|
37
|
-
);
|
38
|
-
}
|
39
|
-
|
40
34
|
if (literals.length) {
|
41
35
|
context.addMigration({
|
42
36
|
description: "Migrate template with non standard template literals",
|
@@ -46,16 +40,16 @@ module.exports = function migrator(el, context) {
|
|
46
40
|
type: "confirm",
|
47
41
|
message:
|
48
42
|
"Non standard template literals convert null/undefined/false to empty strings, JavaScript template literals do not. If you are relying on this it may cause issues. Would you like to attempt to migrate?",
|
49
|
-
initial: true
|
43
|
+
initial: true,
|
50
44
|
})
|
51
|
-
.then(shouldMigrate => {
|
45
|
+
.then((shouldMigrate) => {
|
52
46
|
if (shouldMigrate) {
|
53
|
-
literals.forEach(node => {
|
47
|
+
literals.forEach((node) => {
|
54
48
|
node.expressions = node._originalExpressions;
|
55
49
|
});
|
56
50
|
}
|
57
51
|
});
|
58
|
-
}
|
52
|
+
},
|
59
53
|
});
|
60
54
|
}
|
61
55
|
};
|
@@ -22,16 +22,12 @@ module.exports = function migrator(el, context) {
|
|
22
22
|
return;
|
23
23
|
}
|
24
24
|
|
25
|
-
context.deprecate(
|
26
|
-
"Directly rendering by passing `out` to a function is deprecated. Please use the dynamic tag instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-imperative-render-calls"
|
27
|
-
);
|
28
|
-
|
29
25
|
if (hasErrors) {
|
30
26
|
return;
|
31
27
|
}
|
32
28
|
|
33
29
|
if (!replacement.type) {
|
34
|
-
replacement.forEachChild(child => node.insertSiblingBefore(child));
|
30
|
+
replacement.forEachChild((child) => node.insertSiblingBefore(child));
|
35
31
|
node.detach();
|
36
32
|
} else {
|
37
33
|
node.replaceWith(replacement);
|
@@ -41,14 +37,14 @@ module.exports = function migrator(el, context) {
|
|
41
37
|
const builder = context.builder;
|
42
38
|
if (!node.type) {
|
43
39
|
if (node.replaceChild) {
|
44
|
-
node.forEach(child => {
|
40
|
+
node.forEach((child) => {
|
45
41
|
const replacement = replaceScriptlets(child, context);
|
46
42
|
if (child !== replacement) {
|
47
43
|
node.replaceChild(replacement, child);
|
48
44
|
}
|
49
45
|
});
|
50
46
|
} else if (node.body) {
|
51
|
-
node.body.forEach(child => {
|
47
|
+
node.body.forEach((child) => {
|
52
48
|
const replacement = replaceScriptlets(child, context);
|
53
49
|
if (child !== replacement) {
|
54
50
|
node.body.replaceChild(replacement, child);
|
@@ -128,7 +124,7 @@ module.exports = function migrator(el, context) {
|
|
128
124
|
|
129
125
|
return node;
|
130
126
|
}
|
131
|
-
}
|
127
|
+
},
|
132
128
|
});
|
133
129
|
walker.walk(el);
|
134
130
|
};
|
@@ -7,9 +7,9 @@ module.exports = function migrator(el, context) {
|
|
7
7
|
apply() {
|
8
8
|
context.root.prependChild(
|
9
9
|
context.builder.scriptlet({
|
10
|
-
value: "var data = component.getTemplateData(state, input)"
|
10
|
+
value: "var data = component.getTemplateData(state, input)",
|
11
11
|
})
|
12
12
|
);
|
13
|
-
}
|
13
|
+
},
|
14
14
|
});
|
15
15
|
};
|
@@ -7,10 +7,6 @@ module.exports = function migrator(elNode, context) {
|
|
7
7
|
commonTagMigrator(elNode, context);
|
8
8
|
elNode.setTransformerApplied(commonTagMigrator);
|
9
9
|
|
10
|
-
context.deprecate(
|
11
|
-
'The "<assign>" tag is deprecated. Please use "$ <js_code>" for JavaScript in the template. See: https://github.com/marko-js/marko/wiki/Deprecation:-var,-assign,-invoke-tags'
|
12
|
-
);
|
13
|
-
|
14
10
|
if (!attributes) {
|
15
11
|
context.addError(
|
16
12
|
"Invalid <assign> tag. Argument is missing. Example; <assign x=123 />"
|
@@ -18,13 +14,13 @@ module.exports = function migrator(elNode, context) {
|
|
18
14
|
return elNode;
|
19
15
|
}
|
20
16
|
|
21
|
-
elNode.attributes.forEach(attr => {
|
17
|
+
elNode.attributes.forEach((attr) => {
|
22
18
|
elNode.insertSiblingBefore(
|
23
19
|
builder.scriptlet({
|
24
20
|
value:
|
25
21
|
attr.value == null
|
26
22
|
? attr.name
|
27
|
-
: `${attr.name} = ${printJS(attr.value, context, null, true)}
|
23
|
+
: `${attr.name} = ${printJS(attr.value, context, null, true)}`,
|
28
24
|
})
|
29
25
|
);
|
30
26
|
});
|
@@ -2,16 +2,12 @@ const awaitTagMigration = require("./await-tag");
|
|
2
2
|
const newTags = {
|
3
3
|
"async-fragment-placeholder": "await-placeholder",
|
4
4
|
"async-fragment-timeout": "await-timeout",
|
5
|
-
"async-fragment-error": "await-error"
|
5
|
+
"async-fragment-error": "await-error",
|
6
6
|
};
|
7
7
|
module.exports = function migrator(elNode, context) {
|
8
8
|
const builder = context.builder;
|
9
9
|
const attributes = elNode.attributes;
|
10
10
|
|
11
|
-
context.deprecate(
|
12
|
-
`The "<async-fragment>" tag is deprecated. Please use "<await>" instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-async-fragment`
|
13
|
-
);
|
14
|
-
|
15
11
|
if (!attributes || !attributes.length) {
|
16
12
|
context.addError(
|
17
13
|
'Invalid <async-fragment> tag. Argument is missing. Example; <async-fragment data-provider=data.userInfo var="userInfo" />'
|
@@ -34,7 +30,7 @@ module.exports = function migrator(elNode, context) {
|
|
34
30
|
return;
|
35
31
|
}
|
36
32
|
|
37
|
-
elNode.forEachChild(child => {
|
33
|
+
elNode.forEachChild((child) => {
|
38
34
|
const newTag = newTags[child.tagName];
|
39
35
|
if (newTag) {
|
40
36
|
child.tagName = newTag;
|
@@ -5,10 +5,6 @@ module.exports = function migrator(elNode, context) {
|
|
5
5
|
commonTagMigrator(elNode, context);
|
6
6
|
elNode.setTransformerApplied(commonTagMigrator);
|
7
7
|
|
8
|
-
context.deprecate(
|
9
|
-
`The "<async-fragments>" tag is deprecated. Please use "<await-reorderer>" instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-async-fragment`
|
10
|
-
);
|
11
|
-
|
12
8
|
// all this tag ever did was handling of client reordering
|
13
9
|
// we'll remove the attribute as that's all this new tag does
|
14
10
|
elNode.removeAttribute("client-reorder");
|
@@ -9,10 +9,6 @@ module.exports = function migrator(elNode, context) {
|
|
9
9
|
return;
|
10
10
|
}
|
11
11
|
|
12
|
-
context.deprecate(
|
13
|
-
'The "<await(result from promise)>" syntax has been deprecated, please use the modern syntax of "<await(promise)><@then|result|>". See: https://github.com/marko-js/marko/wiki/Deprecation:-legacy-await'
|
14
|
-
);
|
15
|
-
|
16
12
|
elNode.argument = undefined;
|
17
13
|
let provider = builder.expression(match[2]);
|
18
14
|
const varName = match[1];
|
@@ -20,8 +16,8 @@ module.exports = function migrator(elNode, context) {
|
|
20
16
|
const scopeExpression =
|
21
17
|
elNode.getAttributeValue("scope") || (methodExpression ? provider : null);
|
22
18
|
const argAssignments = elNode.attributes
|
23
|
-
.filter(attr => attr.name && attr.name.startsWith("arg-"))
|
24
|
-
.map(attr => {
|
19
|
+
.filter((attr) => attr.name && attr.name.startsWith("arg-"))
|
20
|
+
.map((attr) => {
|
25
21
|
elNode.removeAttribute(attr.name);
|
26
22
|
return [attr.name.slice(4), attr.value];
|
27
23
|
});
|
@@ -50,14 +46,14 @@ module.exports = function migrator(elNode, context) {
|
|
50
46
|
builder.scriptlet({
|
51
47
|
value: printJS(
|
52
48
|
builder.vars({
|
53
|
-
arg: argExpression
|
49
|
+
arg: argExpression,
|
54
50
|
}),
|
55
51
|
context
|
56
|
-
)
|
52
|
+
),
|
57
53
|
})
|
58
54
|
);
|
59
55
|
|
60
|
-
argAssignments.forEach(assignment => {
|
56
|
+
argAssignments.forEach((assignment) => {
|
61
57
|
elNode.insertSiblingBefore(
|
62
58
|
builder.scriptlet({
|
63
59
|
value: printJS(
|
@@ -71,7 +67,7 @@ module.exports = function migrator(elNode, context) {
|
|
71
67
|
"="
|
72
68
|
),
|
73
69
|
context
|
74
|
-
)
|
70
|
+
),
|
75
71
|
})
|
76
72
|
);
|
77
73
|
});
|
@@ -102,34 +98,23 @@ module.exports = function migrator(elNode, context) {
|
|
102
98
|
|
103
99
|
let placeholderBody;
|
104
100
|
if (elNode.hasAttribute("placeholder")) {
|
105
|
-
context.deprecate(
|
106
|
-
'The "placeholder" attribute on the "<await>" tag is deprecated. Please use the "<@placeholder>" nested tag instead.'
|
107
|
-
);
|
108
|
-
|
109
101
|
placeholderBody = [builder.text(elNode.getAttributeValue("placeholder"))];
|
110
102
|
elNode.removeAttribute("placeholder");
|
111
103
|
}
|
112
104
|
|
113
105
|
let timeoutBody;
|
114
106
|
if (elNode.hasAttribute("timeout-message")) {
|
115
|
-
context.deprecate(
|
116
|
-
'The "timeout-message" attribute on the "<await>" tag is deprecated. Please use the "<@catch|err|>" nested tag instead with a check for "err.name === "TimeoutError".'
|
117
|
-
);
|
118
|
-
|
119
107
|
timeoutBody = [builder.text(elNode.getAttributeValue("timeout-message"))];
|
120
108
|
elNode.removeAttribute("timeout-message");
|
121
109
|
}
|
122
110
|
|
123
111
|
let errorBody;
|
124
112
|
if (elNode.hasAttribute("error-message")) {
|
125
|
-
context.deprecate(
|
126
|
-
'The "error-message" attribute on the "<await>" tag is deprecated. Please use the "<@catch>" nested tag instead.'
|
127
|
-
);
|
128
113
|
errorBody = [builder.text(elNode.getAttributeValue("error-message"))];
|
129
114
|
elNode.removeAttribute("error-message");
|
130
115
|
}
|
131
116
|
|
132
|
-
elNode.forEachChild(childNode => {
|
117
|
+
elNode.forEachChild((childNode) => {
|
133
118
|
if (childNode.type !== "HtmlElement") {
|
134
119
|
return;
|
135
120
|
}
|
@@ -202,7 +187,7 @@ module.exports = function migrator(elNode, context) {
|
|
202
187
|
undefined,
|
203
188
|
timeoutBody,
|
204
189
|
'err.name === "TimeoutError"'
|
205
|
-
)
|
190
|
+
),
|
206
191
|
];
|
207
192
|
|
208
193
|
if (originalErrorBody) {
|
@@ -11,9 +11,5 @@ module.exports = function migrator(el, context) {
|
|
11
11
|
);
|
12
12
|
}
|
13
13
|
|
14
|
-
context.deprecate(
|
15
|
-
"Having a named class at the top level of a file is deprecated. Use `class {...}` without a name instead."
|
16
|
-
);
|
17
|
-
|
18
14
|
el.tagString = el.tagString.replace(classNamedRegexp, "$1$2");
|
19
15
|
};
|
@@ -1,7 +1,3 @@
|
|
1
1
|
module.exports = function render(elNode, context) {
|
2
|
-
context.deprecate(
|
3
|
-
"The <component-globals> tag is deprecated. This functionality has been added to the '<init-components>' tag (which is automatically inserted at the end of the <body> tag), you can safely remove the '<component-globals>' tag."
|
4
|
-
);
|
5
|
-
|
6
2
|
elNode.detach();
|
7
3
|
};
|
@@ -21,10 +21,6 @@ function migrateForLoop(elNode, context) {
|
|
21
21
|
return;
|
22
22
|
}
|
23
23
|
|
24
|
-
context.deprecate(
|
25
|
-
'The "<for(...)>" syntax has been deprecated, checkout the modern syntax here: https://github.com/marko-js/marko/wiki/Deprecation:-legacy-for'
|
26
|
-
);
|
27
|
-
|
28
24
|
try {
|
29
25
|
parsed = parseFor(elNode.argument);
|
30
26
|
elNode.argument = undefined;
|
@@ -80,10 +76,10 @@ function migrateForLoop(elNode, context) {
|
|
80
76
|
builder.variableDeclarator(
|
81
77
|
iteratorResultName,
|
82
78
|
builder.arrayExpression([])
|
83
|
-
)
|
79
|
+
),
|
84
80
|
]),
|
85
81
|
context
|
86
|
-
)
|
82
|
+
),
|
87
83
|
})
|
88
84
|
);
|
89
85
|
|
@@ -102,12 +98,12 @@ function migrateForLoop(elNode, context) {
|
|
102
98
|
builder.identifier("push")
|
103
99
|
),
|
104
100
|
[itemName]
|
105
|
-
)
|
101
|
+
),
|
106
102
|
]
|
107
|
-
)
|
103
|
+
),
|
108
104
|
]),
|
109
105
|
context
|
110
|
-
)
|
106
|
+
),
|
111
107
|
})
|
112
108
|
);
|
113
109
|
|
@@ -172,7 +168,7 @@ function migrateForLoop(elNode, context) {
|
|
172
168
|
builder.memberExpression(parsed.in, parsed.nameVarName, true)
|
173
169
|
),
|
174
170
|
context
|
175
|
-
)
|
171
|
+
),
|
176
172
|
})
|
177
173
|
);
|
178
174
|
|
@@ -208,7 +204,7 @@ function migrateForLoop(elNode, context) {
|
|
208
204
|
elNode.insertSiblingBefore(
|
209
205
|
builder.scriptlet({
|
210
206
|
value: printJS(parsed.init, context),
|
211
|
-
block: true
|
207
|
+
block: true,
|
212
208
|
})
|
213
209
|
);
|
214
210
|
}
|
@@ -217,7 +213,7 @@ function migrateForLoop(elNode, context) {
|
|
217
213
|
elNode.appendChild(
|
218
214
|
builder.scriptlet({
|
219
215
|
value: printJS(parsed.update, context),
|
220
|
-
block: true
|
216
|
+
block: true,
|
221
217
|
})
|
222
218
|
);
|
223
219
|
}
|
@@ -329,7 +325,7 @@ function normalizeParts(parsed, builder) {
|
|
329
325
|
varName: varName,
|
330
326
|
from: from,
|
331
327
|
to: to,
|
332
|
-
step: step
|
328
|
+
step: step,
|
333
329
|
};
|
334
330
|
}
|
335
331
|
|
@@ -354,7 +350,7 @@ function replaceStatusVarInBody(el, context, parsed) {
|
|
354
350
|
indexIdentifier,
|
355
351
|
"===",
|
356
352
|
builder.binaryExpression(lengthIdentifier, "-", builder.literal(1))
|
357
|
-
)
|
353
|
+
),
|
358
354
|
};
|
359
355
|
|
360
356
|
const remapKeys = Object.keys(remaps);
|
@@ -373,7 +369,7 @@ function replaceStatusVarInBody(el, context, parsed) {
|
|
373
369
|
`${statusVarName}\\.(${remapKeys.join("|")})\\(\\)`,
|
374
370
|
"g"
|
375
371
|
);
|
376
|
-
const remapReplacer = str =>
|
372
|
+
const remapReplacer = (str) =>
|
377
373
|
str.replace(remapRegexp, (_, key) => remapStrings[key]);
|
378
374
|
const visitor = {
|
379
375
|
enter(node) {
|
@@ -402,7 +398,7 @@ function replaceStatusVarInBody(el, context, parsed) {
|
|
402
398
|
this.skip();
|
403
399
|
}
|
404
400
|
}
|
405
|
-
}
|
401
|
+
},
|
406
402
|
};
|
407
403
|
|
408
404
|
context.createWalker(visitor).walk(el.body);
|
@@ -5,9 +5,6 @@ const commonTagMigrator = require("./all-tags");
|
|
5
5
|
module.exports = function migrator(elNode, context) {
|
6
6
|
commonTagMigrator(elNode, context);
|
7
7
|
elNode.setTransformerApplied(commonTagMigrator);
|
8
|
-
context.deprecate(
|
9
|
-
'The "<include>" tag is deprecated. Please use the "<${dynamic}/>" tag or regular text replacement instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-include-tag'
|
10
|
-
);
|
11
8
|
|
12
9
|
const builder = context.builder;
|
13
10
|
const rawArg = elNode.argument;
|
@@ -53,8 +50,8 @@ module.exports = function migrator(elNode, context) {
|
|
53
50
|
elNode.insertSiblingBefore(
|
54
51
|
builder.scriptlet({
|
55
52
|
value: builder.vars({
|
56
|
-
[identifierName]: target
|
57
|
-
})
|
53
|
+
[identifierName]: target,
|
54
|
+
}),
|
58
55
|
})
|
59
56
|
);
|
60
57
|
|
@@ -8,10 +8,6 @@ module.exports = function migrator(elNode, context) {
|
|
8
8
|
const functionAttr = elNode.attributes[0];
|
9
9
|
const functionArgs = functionAttr.argument;
|
10
10
|
|
11
|
-
context.deprecate(
|
12
|
-
'The "<invoke>" tag is deprecated. Please use "$ <js_code>" for JavaScript in the template. See: https://github.com/marko-js/marko/wiki/Deprecation:-var,-assign,-invoke-tags'
|
13
|
-
);
|
14
|
-
|
15
11
|
if (!functionAttr) {
|
16
12
|
context.addError(
|
17
13
|
'Invalid <invoke> tag. Missing function attribute. Expected: <invoke console.log("Hello World")'
|
@@ -31,14 +27,14 @@ module.exports = function migrator(elNode, context) {
|
|
31
27
|
let replacement = renderCallToDynamicTag(functionAst, context);
|
32
28
|
|
33
29
|
if (replacement) {
|
34
|
-
elNode.forEachAttribute(attr => {
|
30
|
+
elNode.forEachAttribute((attr) => {
|
35
31
|
if (attr !== functionAttr) {
|
36
32
|
replacement.addAttribute(attr);
|
37
33
|
}
|
38
34
|
});
|
39
35
|
} else {
|
40
36
|
replacement = builder.scriptlet({
|
41
|
-
value: functionCallExpression
|
37
|
+
value: functionCallExpression,
|
42
38
|
});
|
43
39
|
}
|
44
40
|
|
@@ -5,9 +5,6 @@ const commonTagMigrator = require("./all-tags");
|
|
5
5
|
module.exports = function render(elNode, context) {
|
6
6
|
commonTagMigrator(elNode, context);
|
7
7
|
elNode.setTransformerApplied(commonTagMigrator);
|
8
|
-
context.deprecate(
|
9
|
-
"The <layout-placeholder> tag is deprecated. Please use the <${dynamic}> tag instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-layout-tag"
|
10
|
-
);
|
11
8
|
|
12
9
|
const builder = context.builder;
|
13
10
|
const name = elNode.getAttributeValue("name");
|
@@ -3,9 +3,6 @@ const commonTagMigrator = require("./all-tags");
|
|
3
3
|
module.exports = function migrator(oldNode, context) {
|
4
4
|
commonTagMigrator(oldNode, context);
|
5
5
|
oldNode.setTransformerApplied(commonTagMigrator);
|
6
|
-
context.deprecate(
|
7
|
-
'The "<layout-put>" tag is deprecated and replaced with first class language support. See: https://github.com/marko-js/marko/wiki/Deprecation:-layout-tag'
|
8
|
-
);
|
9
6
|
|
10
7
|
const attributes = oldNode.attributes;
|
11
8
|
if (!attributes) {
|
@@ -5,9 +5,6 @@ const commonTagMigrator = require("./all-tags");
|
|
5
5
|
module.exports = function render(elNode, context) {
|
6
6
|
commonTagMigrator(elNode, context);
|
7
7
|
elNode.setTransformerApplied(commonTagMigrator);
|
8
|
-
context.deprecate(
|
9
|
-
"The <layout-use> tag is deprecated. Please use a combination of the <${dynamic}> tag and imports instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-layout-tag"
|
10
|
-
);
|
11
8
|
|
12
9
|
const rawArg = elNode.argument;
|
13
10
|
const attributes = elNode.attributes;
|
@@ -1,9 +1,4 @@
|
|
1
1
|
module.exports = function codeGenerator(elNode, context) {
|
2
|
-
context.deprecate(
|
3
|
-
'The "<macro-body>" tag has been deprecated. Please use the <${dynamic}/> tag instead, eg: "<macro|input| ...><${input.renderBody}/></macro>". See: https://github.com/marko-js/marko/wiki/Deprecation:-legacy-macro',
|
4
|
-
elNode
|
5
|
-
);
|
6
|
-
|
7
2
|
const builder = context.builder;
|
8
3
|
const dynamicTag = builder.htmlElement(undefined, elNode.attributes);
|
9
4
|
dynamicTag.rawTagNameExpression = "macroInput";
|
@@ -8,7 +8,7 @@ module.exports = function migrator(elNode, context) {
|
|
8
8
|
if (
|
9
9
|
!attributes.length ||
|
10
10
|
attributes.some(
|
11
|
-
attr => attr.name === "name" && attr.value.type === "Literal"
|
11
|
+
(attr) => attr.name === "name" && attr.value.type === "Literal"
|
12
12
|
)
|
13
13
|
) {
|
14
14
|
return;
|
@@ -22,11 +22,6 @@ module.exports = function migrator(elNode, context) {
|
|
22
22
|
return elNode;
|
23
23
|
}
|
24
24
|
|
25
|
-
context.deprecate(
|
26
|
-
'The "<macro my-macro(input)>" syntax has been deprecated. Please use the new tag param syntax, eg: "<macro|input| name="my-macro">. See: https://github.com/marko-js/marko/wiki/Deprecation:-legacy-macro',
|
27
|
-
elNode
|
28
|
-
);
|
29
|
-
|
30
25
|
const name = defAttr.name;
|
31
26
|
const params = defAttr.argument
|
32
27
|
? builder.parseJavaScriptParams(defAttr.argument)
|
@@ -48,7 +43,7 @@ module.exports = function migrator(elNode, context) {
|
|
48
43
|
params.push(builder.identifier("renderBody"));
|
49
44
|
macroWalker.stop();
|
50
45
|
}
|
51
|
-
}
|
46
|
+
},
|
52
47
|
});
|
53
48
|
|
54
49
|
macroWalker.walk(elNode);
|
@@ -56,7 +51,7 @@ module.exports = function migrator(elNode, context) {
|
|
56
51
|
params
|
57
52
|
.slice()
|
58
53
|
.reverse()
|
59
|
-
.forEach(param => {
|
54
|
+
.forEach((param) => {
|
60
55
|
const name = builder.identifier(param.name);
|
61
56
|
const value = builder.memberExpression(
|
62
57
|
builder.identifier("macroInput"),
|
@@ -67,7 +62,7 @@ module.exports = function migrator(elNode, context) {
|
|
67
62
|
value: printJS(
|
68
63
|
builder.vars([builder.variableDeclarator(name, value)]),
|
69
64
|
context
|
70
|
-
)
|
65
|
+
),
|
71
66
|
})
|
72
67
|
);
|
73
68
|
});
|
@@ -90,7 +85,7 @@ module.exports = function migrator(elNode, context) {
|
|
90
85
|
child.addAttribute({ name: name, value: value });
|
91
86
|
}
|
92
87
|
}
|
93
|
-
}
|
88
|
+
},
|
94
89
|
});
|
95
90
|
|
96
91
|
templateWalker.walk(context.root);
|
@@ -4,9 +4,6 @@ module.exports = function migrator(oldNode, context) {
|
|
4
4
|
const attributes = oldNode.attributes;
|
5
5
|
const argument = oldNode.argument;
|
6
6
|
|
7
|
-
context.deprecate(
|
8
|
-
'The "<unless(x)>" tag is deprecated. Please use "<if(!x)>" instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-unless-tag'
|
9
|
-
);
|
10
7
|
if (!argument) {
|
11
8
|
context.addError(
|
12
9
|
"Invalid <unless> tag. Argument is missing. Example; <unless(foo === true)>"
|