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
@@ -5,8 +5,8 @@ var coreAttrHandlers = [
|
|
5
5
|
"marko-preserve-whitespace",
|
6
6
|
function (attr, node, el) {
|
7
7
|
el.setPreserveWhitespace(true);
|
8
|
-
}
|
9
|
-
]
|
8
|
+
},
|
9
|
+
],
|
10
10
|
];
|
11
11
|
|
12
12
|
class AttributeTransformer {
|
@@ -19,7 +19,7 @@ class AttributeTransformer {
|
|
19
19
|
addError(message) {
|
20
20
|
this.context.addError({
|
21
21
|
node: this.el,
|
22
|
-
message: message
|
22
|
+
message: message,
|
23
23
|
});
|
24
24
|
}
|
25
25
|
}
|
@@ -47,7 +47,7 @@ module.exports = function transform(el, context) {
|
|
47
47
|
params: el.params,
|
48
48
|
openTagOnly: el.openTagOnly,
|
49
49
|
selfClosed: el.selfClosed,
|
50
|
-
body: el.body
|
50
|
+
body: el.body,
|
51
51
|
}))
|
52
52
|
);
|
53
53
|
}
|
@@ -55,7 +55,7 @@ module.exports = function transform(el, context) {
|
|
55
55
|
var attributeTransfomer;
|
56
56
|
var node = el;
|
57
57
|
|
58
|
-
el.forEachAttribute(attr => {
|
58
|
+
el.forEachAttribute((attr) => {
|
59
59
|
let attrName = attr.name;
|
60
60
|
var attrTransformerFunc = attributeTransformers[attrName];
|
61
61
|
if (attrTransformerFunc) {
|
@@ -12,7 +12,7 @@ module.exports = function codeGenerator(elNode, codegen) {
|
|
12
12
|
Array.from(body.slice(1)).reduce((expr, current) => {
|
13
13
|
return builder.binaryExpression(expr, "+", current.argument);
|
14
14
|
}, body[0].argument),
|
15
|
-
builder.identifier("component")
|
15
|
+
builder.identifier("component"),
|
16
16
|
]
|
17
17
|
);
|
18
18
|
};
|
@@ -4,13 +4,13 @@ function getSpecifiers(importDeclaration) {
|
|
4
4
|
var match = /^([\s\S]+)\bfrom\s*(("|')(.*?)("|'))$/.exec(importDeclaration);
|
5
5
|
if (!match) {
|
6
6
|
return {
|
7
|
-
moduleSpecifier: importDeclaration.replace(/"|'/g, "").trim()
|
7
|
+
moduleSpecifier: importDeclaration.replace(/"|'/g, "").trim(),
|
8
8
|
};
|
9
9
|
}
|
10
10
|
|
11
11
|
return {
|
12
12
|
importSpecifierSet: match[1].trim(),
|
13
|
-
moduleSpecifier: match[4].trim()
|
13
|
+
moduleSpecifier: match[4].trim(),
|
14
14
|
};
|
15
15
|
}
|
16
16
|
|
@@ -23,12 +23,12 @@ function getImportSpecifierGroups(importSpecifierSet) {
|
|
23
23
|
defaultImport = defaultImport.replace(decomposedImports[0], "");
|
24
24
|
decomposedImports = decomposedImports[1]
|
25
25
|
.split(",")
|
26
|
-
.map(specifier => specifier.trim());
|
26
|
+
.map((specifier) => specifier.trim());
|
27
27
|
}
|
28
28
|
|
29
29
|
return {
|
30
30
|
defaultImport: defaultImport,
|
31
|
-
decomposedImports: decomposedImports
|
31
|
+
decomposedImports: decomposedImports,
|
32
32
|
};
|
33
33
|
}
|
34
34
|
|
@@ -51,7 +51,7 @@ function getNames(importSpecifier) {
|
|
51
51
|
|
52
52
|
return {
|
53
53
|
exported: names[0].trim(),
|
54
|
-
local: names[1].trim()
|
54
|
+
local: names[1].trim(),
|
55
55
|
};
|
56
56
|
}
|
57
57
|
|
@@ -71,13 +71,13 @@ module.exports = function importToAssignments(tagString) {
|
|
71
71
|
getVariableName(moduleSpecifier);
|
72
72
|
var specifierList = importGroups.decomposedImports
|
73
73
|
.map(getNames)
|
74
|
-
.map(names => {
|
74
|
+
.map((names) => {
|
75
75
|
return {
|
76
76
|
name: names.local,
|
77
77
|
value: {
|
78
78
|
object: rootVariable,
|
79
|
-
property: names.exported
|
80
|
-
}
|
79
|
+
property: names.exported,
|
80
|
+
},
|
81
81
|
};
|
82
82
|
});
|
83
83
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module.exports = function codeGenerator(elNode, codegen) {
|
2
2
|
const builder = codegen.builder;
|
3
|
-
const body = elNode.body.array.map(text => text.argument);
|
3
|
+
const body = elNode.body.array.map((text) => text.argument);
|
4
4
|
if (body.length > 1) {
|
5
5
|
const quasis = [];
|
6
6
|
const expressions = [];
|
@@ -4,15 +4,14 @@ module.exports = function migrator(node, context) {
|
|
4
4
|
const arg = node.getAttribute("body-only-if");
|
5
5
|
|
6
6
|
if (arg) {
|
7
|
-
context.deprecate(
|
8
|
-
'The "body-only-if(x)" tag is deprecated. Please use "<${test ? null : tag>" instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-body‐only‐if'
|
9
|
-
);
|
10
7
|
// Check if body-only-if(true) is set and automatically unwrap element
|
11
8
|
if (arg.argument === "true") {
|
12
9
|
// w-body will take care of the unwrapping
|
13
10
|
if (!node.getAttribute("w-body")) {
|
14
11
|
// Unwrap if there is no w-body tag
|
15
|
-
node.forEachChild(currentNode =>
|
12
|
+
node.forEachChild((currentNode) =>
|
13
|
+
node.insertSiblingBefore(currentNode)
|
14
|
+
);
|
16
15
|
node.detach();
|
17
16
|
}
|
18
17
|
return;
|
@@ -34,7 +33,7 @@ module.exports = function migrator(node, context) {
|
|
34
33
|
|
35
34
|
if (!tagDef.html && tagDef.renderer) {
|
36
35
|
tagName = builder.objectExpression({
|
37
|
-
renderer: builder.identifier(tagName)
|
36
|
+
renderer: builder.identifier(tagName),
|
38
37
|
});
|
39
38
|
}
|
40
39
|
|
@@ -4,22 +4,19 @@ const CONTROL_FLOW_ATTRIBUTES = [
|
|
4
4
|
"if",
|
5
5
|
"unless",
|
6
6
|
"else-if",
|
7
|
-
"else"
|
7
|
+
"else",
|
8
8
|
];
|
9
9
|
|
10
10
|
module.exports = function migrate(el, context) {
|
11
11
|
const builder = context.builder;
|
12
12
|
|
13
|
-
el.forEachAttribute(attr => {
|
13
|
+
el.forEachAttribute((attr) => {
|
14
14
|
const name = attr.name;
|
15
15
|
if (
|
16
16
|
CONTROL_FLOW_ATTRIBUTES.includes(name) &&
|
17
17
|
(name === "else" || attr.argument) &&
|
18
18
|
!(el.tagName === "else" && name === "if") // <else if(x)> gets passed through
|
19
19
|
) {
|
20
|
-
context.deprecate(
|
21
|
-
`The "${name}" attribute is deprecated. Please use the <${name}> tag instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-control-flow-attributes`
|
22
|
-
);
|
23
20
|
el.removeAttribute(name);
|
24
21
|
el.wrapWith(
|
25
22
|
builder.htmlElement(name, undefined, undefined, attr.argument)
|
@@ -1,9 +1,6 @@
|
|
1
|
-
module.exports = function migrate(el
|
1
|
+
module.exports = function migrate(el) {
|
2
2
|
el.forEachAttribute((attr, index) => {
|
3
3
|
if (!attr.name && !attr.spread) {
|
4
|
-
context.deprecate(
|
5
|
-
'The "${attributes}" is deprecated. Please use "...attributes" modifier instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-w‐*-Attributes'
|
6
|
-
);
|
7
4
|
const attribute = el.attributes.splice(index, 1)[0];
|
8
5
|
attribute.spread = true;
|
9
6
|
el.attributes.unshift(attribute);
|
@@ -6,10 +6,6 @@ module.exports = function migrate(el, context) {
|
|
6
6
|
return;
|
7
7
|
}
|
8
8
|
|
9
|
-
context.deprecate(
|
10
|
-
'The "include" attribute is deprecated. Please use the <${dynamic}> tag instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-include-tag'
|
11
|
-
);
|
12
|
-
|
13
9
|
el.removeAttribute("include");
|
14
10
|
el.appendChild(
|
15
11
|
builder.htmlElement("include", undefined, undefined, attr.argument)
|
@@ -17,13 +17,13 @@ const commonMigrators = [
|
|
17
17
|
require("./w-on"),
|
18
18
|
require("./w-preserve"),
|
19
19
|
require("./w-preserve-attrs"),
|
20
|
-
require("./widget-in-attrs")
|
20
|
+
require("./widget-in-attrs"),
|
21
21
|
];
|
22
22
|
|
23
23
|
module.exports = function (el, context) {
|
24
24
|
if (el.detachNode) {
|
25
25
|
return false;
|
26
26
|
}
|
27
|
-
commonMigrators.forEach(migrator => migrator(el, context));
|
27
|
+
commonMigrators.forEach((migrator) => migrator(el, context));
|
28
28
|
return true;
|
29
29
|
};
|
@@ -12,9 +12,4 @@ module.exports = function migrate(el, context) {
|
|
12
12
|
|
13
13
|
const nestedTagName = match[1];
|
14
14
|
el.tagName = `@${nestedTagName}`;
|
15
|
-
|
16
|
-
context.deprecate(
|
17
|
-
'The "<my-tag:nested>" tagName syntax is deprecated. Please use the "<@nested>" tagName syntax instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-legacy-nested-tags',
|
18
|
-
el
|
19
|
-
);
|
20
15
|
};
|
@@ -5,7 +5,7 @@ const SAFE_TO_PRINT_ON_ONE_LINE = [
|
|
5
5
|
"ElseIf",
|
6
6
|
"ForStatement",
|
7
7
|
"WhileStatement",
|
8
|
-
"FunctionDeclaration"
|
8
|
+
"FunctionDeclaration",
|
9
9
|
];
|
10
10
|
|
11
11
|
module.exports = function migrate(el, context) {
|
@@ -17,9 +17,6 @@ module.exports = function migrate(el, context) {
|
|
17
17
|
return;
|
18
18
|
}
|
19
19
|
|
20
|
-
context.deprecate(
|
21
|
-
'The "marko-init" attribute is deprecated. Use the static tag instead. See https://github.com/marko-js/marko/wiki/Deprecation:-script-template-helpers'
|
22
|
-
);
|
23
20
|
el.removeAttribute("marko-init");
|
24
21
|
} else if (el.hasAttribute("template-helpers")) {
|
25
22
|
if (el.tagName !== "script") {
|
@@ -29,9 +26,6 @@ module.exports = function migrate(el, context) {
|
|
29
26
|
return;
|
30
27
|
}
|
31
28
|
|
32
|
-
context.deprecate(
|
33
|
-
'The "template-helpers" attribute is deprecated and will be removed in the next release candidate. Use the static tag instead. See https://github.com/marko-js/marko/wiki/Deprecation:-script-template-helpers'
|
34
|
-
);
|
35
29
|
el.removeAttribute("template-helpers");
|
36
30
|
} else {
|
37
31
|
return;
|
@@ -50,7 +44,7 @@ module.exports = function migrate(el, context) {
|
|
50
44
|
if (!child.type) {
|
51
45
|
child.forEachChild(insertStaticOrImport);
|
52
46
|
} else if (child.type === "Vars") {
|
53
|
-
child.declarations.forEach(declaration => {
|
47
|
+
child.declarations.forEach((declaration) => {
|
54
48
|
const id = declaration.id;
|
55
49
|
const init = declaration.init;
|
56
50
|
el.insertSiblingBefore(
|
@@ -2,23 +2,17 @@ const addIdScopedAttr = require("../util/addIdScopedAttr");
|
|
2
2
|
const componentElId = /^component\.(?:getE|e)lId\(.*\)$/;
|
3
3
|
|
4
4
|
module.exports = function migrate(el, context) {
|
5
|
-
el.forEachAttribute(attr => {
|
5
|
+
el.forEachAttribute((attr) => {
|
6
6
|
let name = attr.name;
|
7
7
|
let value = attr.value;
|
8
8
|
|
9
9
|
if (name && name.endsWith(":key")) {
|
10
|
-
context.deprecate(
|
11
|
-
`The ":key" modifier is deprecated. Please use ":scoped" modifier instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-w‐*-Attributes`
|
12
|
-
);
|
13
10
|
name = name.slice(0, 0 - ":key".length) + ":scoped";
|
14
11
|
} else if (
|
15
12
|
value &&
|
16
13
|
value.type === "FunctionCall" &&
|
17
14
|
componentElId.test(attr.rawValue)
|
18
15
|
) {
|
19
|
-
context.deprecate(
|
20
|
-
`Using component.${value.callee.property.name} as an attribute is deprecated. Please use ":scoped" modifier instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-w‐*-Attributes`
|
21
|
-
);
|
22
16
|
name += ":scoped";
|
23
17
|
value = value.args[0];
|
24
18
|
} else {
|
@@ -17,7 +17,7 @@ function enableTagParams(el, context) {
|
|
17
17
|
el.params = context.builder.parseJavaScriptParams(el.argument);
|
18
18
|
delete el.argument;
|
19
19
|
}
|
20
|
-
el.forEachChild(childNode => {
|
20
|
+
el.forEachChild((childNode) => {
|
21
21
|
if (isNestedTag(childNode)) {
|
22
22
|
enableTagParams(childNode, context);
|
23
23
|
}
|
@@ -1,13 +1,9 @@
|
|
1
|
-
module.exports = function migrate(el
|
1
|
+
module.exports = function migrate(el) {
|
2
2
|
const attr = el.getAttribute("ref");
|
3
3
|
if (!attr) {
|
4
4
|
return;
|
5
5
|
}
|
6
6
|
|
7
|
-
context.deprecate(
|
8
|
-
`The "ref" attribute is deprecated. Please use "key" attribute instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-ref-attribute`
|
9
|
-
);
|
10
|
-
|
11
7
|
el.setAttributeValue("key", attr.value);
|
12
8
|
el.removeAttribute(attr.name);
|
13
9
|
};
|
@@ -14,10 +14,6 @@ module.exports = function migrate(el, context) {
|
|
14
14
|
|
15
15
|
context.setMeta("legacy", true);
|
16
16
|
|
17
|
-
context.deprecate(
|
18
|
-
"Legacy components using w-bind and defineRenderer/defineComponent or defineComponent are deprecated. See: https://github.com/marko-js/marko/issues/421"
|
19
|
-
);
|
20
|
-
|
21
17
|
if (value == null) {
|
22
18
|
componentModule = getDefaultWidgetFile(context.dirname);
|
23
19
|
|
@@ -54,7 +50,7 @@ module.exports = function migrate(el, context) {
|
|
54
50
|
componentModule = {
|
55
51
|
legacy: true,
|
56
52
|
filename,
|
57
|
-
requirePath: literalValue
|
53
|
+
requirePath: literalValue,
|
58
54
|
};
|
59
55
|
}
|
60
56
|
|
@@ -80,18 +76,18 @@ module.exports = function migrate(el, context) {
|
|
80
76
|
message:
|
81
77
|
"A widget file was discovered, would you like to migrate that as well?\n" +
|
82
78
|
"Note: widget migrations are not 100% safe and should be tested after migration.",
|
83
|
-
initial: true
|
79
|
+
initial: true,
|
84
80
|
})
|
85
|
-
.then(shouldMigrate => {
|
81
|
+
.then((shouldMigrate) => {
|
86
82
|
if (shouldMigrate) {
|
87
83
|
el.removeAttribute("w-bind");
|
88
84
|
return helpers.run("componentFile", {
|
89
85
|
templateFile: context.filename,
|
90
|
-
componentFile: componentModule.filename
|
86
|
+
componentFile: componentModule.filename,
|
91
87
|
});
|
92
88
|
}
|
93
89
|
});
|
94
|
-
}
|
90
|
+
},
|
95
91
|
});
|
96
92
|
};
|
97
93
|
|
@@ -103,19 +99,19 @@ function getDefaultWidgetFile(dirname) {
|
|
103
99
|
return {
|
104
100
|
filename,
|
105
101
|
requirePath: "./widget",
|
106
|
-
legacy
|
102
|
+
legacy,
|
107
103
|
};
|
108
104
|
} else if ((filename = resolveFrom(dirname, "./component"))) {
|
109
105
|
return {
|
110
106
|
filename,
|
111
107
|
requirePath: "./component",
|
112
|
-
legacy
|
108
|
+
legacy,
|
113
109
|
};
|
114
110
|
} else if ((filename = resolveFrom(dirname, "./"))) {
|
115
111
|
return {
|
116
112
|
filename,
|
117
113
|
requirePath: "./",
|
118
|
-
legacy
|
114
|
+
legacy,
|
119
115
|
};
|
120
116
|
} else {
|
121
117
|
return null;
|
@@ -5,10 +5,6 @@ module.exports = function migrate(el, context) {
|
|
5
5
|
return;
|
6
6
|
}
|
7
7
|
|
8
|
-
context.deprecate(
|
9
|
-
'The "w-body" attribute is deprecated. Please use the "<${dynamicTag}/>" tag instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-Widget-body-(w‐body)'
|
10
|
-
);
|
11
|
-
|
12
8
|
const builder = context.builder;
|
13
9
|
const defaultValue = builder.identifier("input");
|
14
10
|
const bodyValue = el.getAttributeValue("w-body") || defaultValue;
|
@@ -44,15 +40,15 @@ module.exports = function migrate(el, context) {
|
|
44
40
|
)
|
45
41
|
),
|
46
42
|
builder.htmlElement("else", undefined, [
|
47
|
-
builder.text(isDefault ? renderBodyValue : bodyValue)
|
48
|
-
])
|
43
|
+
builder.text(isDefault ? renderBodyValue : bodyValue),
|
44
|
+
]),
|
49
45
|
]);
|
50
46
|
|
51
47
|
if (
|
52
48
|
el.hasAttribute("body-only-if") &&
|
53
49
|
el.getAttribute("body-only-if").argument === "true"
|
54
50
|
) {
|
55
|
-
el.forEachChild(node => el.insertSiblingBefore(node));
|
51
|
+
el.forEachChild((node) => el.insertSiblingBefore(node));
|
56
52
|
el.detach();
|
57
53
|
}
|
58
54
|
};
|
@@ -7,10 +7,6 @@ module.exports = function migrate(el, context) {
|
|
7
7
|
return;
|
8
8
|
}
|
9
9
|
|
10
|
-
context.deprecate(
|
11
|
-
'The "w-config" attribute is deprecated. See: https://github.com/marko-js/marko/wiki/Deprecation:-w‐config'
|
12
|
-
);
|
13
|
-
|
14
10
|
if (attr.value) {
|
15
11
|
el.insertSiblingBefore(
|
16
12
|
builder.scriptlet({
|
@@ -24,7 +20,7 @@ module.exports = function migrate(el, context) {
|
|
24
20
|
"="
|
25
21
|
),
|
26
22
|
context
|
27
|
-
)
|
23
|
+
),
|
28
24
|
})
|
29
25
|
);
|
30
26
|
}
|
@@ -7,7 +7,7 @@ module.exports = function migrate(el, context) {
|
|
7
7
|
el.hasAttribute("for-key") ||
|
8
8
|
el.hasAttribute("for-ref")
|
9
9
|
) {
|
10
|
-
el.forEachAttribute(attr => {
|
10
|
+
el.forEachAttribute((attr) => {
|
11
11
|
const name = attr.name;
|
12
12
|
if (
|
13
13
|
!name ||
|
@@ -17,14 +17,7 @@ module.exports = function migrate(el, context) {
|
|
17
17
|
}
|
18
18
|
|
19
19
|
if (name === "w-for" && !findBoundParent(el)) {
|
20
|
-
context.deprecate(
|
21
|
-
`Using "w-for" in a template without a "w-bind" is deprecated. The "${name}" attribute is also deprecated. Please use "for:scoped" instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-w‐*-Attributes`
|
22
|
-
);
|
23
20
|
context.setMigrationFlag("legacyWidgetAttrsWithoutBind");
|
24
|
-
} else {
|
25
|
-
context.deprecate(
|
26
|
-
`The "${name}" attribute is deprecated. Please use "for:scoped" instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-w‐*-Attributes`
|
27
|
-
);
|
28
21
|
}
|
29
22
|
|
30
23
|
if (el.hasAttribute("for:scoped")) {
|
@@ -6,14 +6,7 @@ module.exports = function migrate(el, context) {
|
|
6
6
|
return;
|
7
7
|
}
|
8
8
|
|
9
|
-
if (findBoundParent(el)) {
|
10
|
-
context.deprecate(
|
11
|
-
`The "w-id" attribute is deprecated. Please use "key" attribute instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-w‐*-Attributes`
|
12
|
-
);
|
13
|
-
} else {
|
14
|
-
context.deprecate(
|
15
|
-
`Using "w-id" in a template without a "w-bind" is deprecated. The "w-id" attribute is also deprecated. Please use "key" attribute instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-w‐*-Attributes`
|
16
|
-
);
|
9
|
+
if (!findBoundParent(el)) {
|
17
10
|
context.setMigrationFlag("legacyWidgetAttrsWithoutBind");
|
18
11
|
}
|
19
12
|
|
@@ -2,20 +2,13 @@ const printJS = require("../util/printJS");
|
|
2
2
|
const findBoundParent = require("../util/findBoundParent");
|
3
3
|
|
4
4
|
module.exports = function migrate(el, context) {
|
5
|
-
el.forEachAttribute(attr => {
|
5
|
+
el.forEachAttribute((attr) => {
|
6
6
|
let name = attr.name;
|
7
7
|
if (!name || !name.startsWith("w-on")) {
|
8
8
|
return;
|
9
9
|
}
|
10
10
|
|
11
|
-
if (findBoundParent(el)) {
|
12
|
-
context.deprecate(
|
13
|
-
`The "w-on*" attributes are deprecated. Please use "on*()" instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-w‐*-Attributes`
|
14
|
-
);
|
15
|
-
} else {
|
16
|
-
context.deprecate(
|
17
|
-
`Using "w-on*" in a template without a "w-bind" is deprecated. The "w-on*" attributes are also deprecated. Please use "on*()" instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-w‐*-Attributes`
|
18
|
-
);
|
11
|
+
if (!findBoundParent(el)) {
|
19
12
|
context.setMigrationFlag("legacyWidgetAttrsWithoutBind");
|
20
13
|
}
|
21
14
|
|
@@ -5,11 +5,7 @@ module.exports = function migrate(el, context) {
|
|
5
5
|
}
|
6
6
|
|
7
7
|
const values = attr.value.value;
|
8
|
-
|
9
|
-
`The "w-preserve-attrs" attribute is deprecated. Please use ":no-update" modifier instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-w‐*-Attributes`
|
10
|
-
);
|
11
|
-
|
12
|
-
values.split(",").forEach(val => {
|
8
|
+
values.split(",").forEach((val) => {
|
13
9
|
const existingAttr = el.getAttribute(val);
|
14
10
|
|
15
11
|
if (existingAttr) {
|
@@ -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
|
};
|