marko 4.26.3 → 4.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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
package/package.json
CHANGED
package/src/compiler/Builder.js
CHANGED
|
@@ -65,7 +65,7 @@ function makeNode(arg) {
|
|
|
65
65
|
} else if (arg == null) {
|
|
66
66
|
return undefined;
|
|
67
67
|
} else if (Array.isArray(arg)) {
|
|
68
|
-
return arg.map(arg => {
|
|
68
|
+
return arg.map((arg) => {
|
|
69
69
|
return makeNode(arg);
|
|
70
70
|
});
|
|
71
71
|
} else {
|
|
@@ -209,7 +209,7 @@ class Builder {
|
|
|
209
209
|
: {
|
|
210
210
|
params: makeNode(params),
|
|
211
211
|
of: makeNode(ofExpression),
|
|
212
|
-
body
|
|
212
|
+
body,
|
|
213
213
|
}
|
|
214
214
|
);
|
|
215
215
|
}
|
|
@@ -221,7 +221,7 @@ class Builder {
|
|
|
221
221
|
: {
|
|
222
222
|
params: makeNode(params),
|
|
223
223
|
in: makeNode(inExpression),
|
|
224
|
-
body
|
|
224
|
+
body,
|
|
225
225
|
}
|
|
226
226
|
);
|
|
227
227
|
}
|
|
@@ -235,7 +235,7 @@ class Builder {
|
|
|
235
235
|
from: makeNode(from),
|
|
236
236
|
to: makeNode(to),
|
|
237
237
|
step: makeNode(step),
|
|
238
|
-
body
|
|
238
|
+
body,
|
|
239
239
|
}
|
|
240
240
|
);
|
|
241
241
|
}
|
|
@@ -299,7 +299,7 @@ class Builder {
|
|
|
299
299
|
body,
|
|
300
300
|
argument,
|
|
301
301
|
openTagOnly,
|
|
302
|
-
selfClosed
|
|
302
|
+
selfClosed,
|
|
303
303
|
});
|
|
304
304
|
}
|
|
305
305
|
}
|
|
@@ -377,7 +377,7 @@ class Builder {
|
|
|
377
377
|
return new Assignment({
|
|
378
378
|
left: moduleExports,
|
|
379
379
|
right: value,
|
|
380
|
-
operator: "="
|
|
380
|
+
operator: "=",
|
|
381
381
|
});
|
|
382
382
|
} else {
|
|
383
383
|
return moduleExports;
|
|
@@ -432,7 +432,7 @@ class Builder {
|
|
|
432
432
|
}
|
|
433
433
|
} else {
|
|
434
434
|
let propertiesObject = properties;
|
|
435
|
-
properties = Object.keys(propertiesObject).map(key => {
|
|
435
|
+
properties = Object.keys(propertiesObject).map((key) => {
|
|
436
436
|
let value = propertiesObject[key];
|
|
437
437
|
if (!(value instanceof Node)) {
|
|
438
438
|
value = value = new Literal({ value });
|
|
@@ -509,7 +509,7 @@ class Builder {
|
|
|
509
509
|
|
|
510
510
|
let callee = new MemberExpression({
|
|
511
511
|
object: new Identifier({ name: "require" }),
|
|
512
|
-
property: new Identifier({ name: "resolve" })
|
|
512
|
+
property: new Identifier({ name: "resolve" }),
|
|
513
513
|
});
|
|
514
514
|
|
|
515
515
|
let args = [path];
|
|
@@ -526,7 +526,7 @@ class Builder {
|
|
|
526
526
|
return new Scriptlet({
|
|
527
527
|
code: scriptlet.value,
|
|
528
528
|
tag: scriptlet.tag,
|
|
529
|
-
block: scriptlet.block
|
|
529
|
+
block: scriptlet.block,
|
|
530
530
|
});
|
|
531
531
|
}
|
|
532
532
|
|
|
@@ -615,11 +615,11 @@ class Builder {
|
|
|
615
615
|
}
|
|
616
616
|
if (typeof declaration === "string") {
|
|
617
617
|
declarations[i] = new VariableDeclarator({
|
|
618
|
-
id: new Identifier({ name: declaration })
|
|
618
|
+
id: new Identifier({ name: declaration }),
|
|
619
619
|
});
|
|
620
620
|
} else if (declaration instanceof Identifier) {
|
|
621
621
|
declarations[i] = new VariableDeclarator({
|
|
622
|
-
id: declaration
|
|
622
|
+
id: declaration,
|
|
623
623
|
});
|
|
624
624
|
} else if (typeof declaration === "object") {
|
|
625
625
|
if (!(declaration instanceof VariableDeclarator)) {
|
|
@@ -640,14 +640,14 @@ class Builder {
|
|
|
640
640
|
|
|
641
641
|
declarations[i] = new VariableDeclarator({
|
|
642
642
|
id,
|
|
643
|
-
init
|
|
643
|
+
init,
|
|
644
644
|
});
|
|
645
645
|
}
|
|
646
646
|
}
|
|
647
647
|
}
|
|
648
648
|
} else if (typeof declarations === "object") {
|
|
649
649
|
// Convert the object into an array of variables
|
|
650
|
-
declarations = Object.keys(declarations).map(key => {
|
|
650
|
+
declarations = Object.keys(declarations).map((key) => {
|
|
651
651
|
let id = new Identifier({ name: key });
|
|
652
652
|
let init = makeNode(declarations[key]);
|
|
653
653
|
return new VariableDeclarator({ id, init });
|
|
@@ -135,12 +135,12 @@ class CodeGenerator {
|
|
|
135
135
|
|
|
136
136
|
_generateCode(node, finalNodes) {
|
|
137
137
|
if (isArray(node)) {
|
|
138
|
-
node.forEach(child => {
|
|
138
|
+
node.forEach((child) => {
|
|
139
139
|
this._generateCode(child, finalNodes);
|
|
140
140
|
});
|
|
141
141
|
return;
|
|
142
142
|
} else if (node instanceof Container) {
|
|
143
|
-
node.forEach(child => {
|
|
143
|
+
node.forEach((child) => {
|
|
144
144
|
if (child.container === node) {
|
|
145
145
|
this._generateCode(child, finalNodes);
|
|
146
146
|
}
|
|
@@ -61,11 +61,11 @@ const helpers = {
|
|
|
61
61
|
merge: "marko/runtime/helpers/merge",
|
|
62
62
|
attr: {
|
|
63
63
|
html: "marko/runtime/html/helpers/attr",
|
|
64
|
-
vdom: "marko/runtime/vdom/helpers/attr"
|
|
64
|
+
vdom: "marko/runtime/vdom/helpers/attr",
|
|
65
65
|
},
|
|
66
66
|
attrs: {
|
|
67
67
|
html: "marko/runtime/html/helpers/attrs",
|
|
68
|
-
vdom: "marko/runtime/vdom/helpers/attrs"
|
|
68
|
+
vdom: "marko/runtime/vdom/helpers/attrs",
|
|
69
69
|
},
|
|
70
70
|
mergeAttrs: { html: "marko/runtime/html/helpers/merge-attrs" },
|
|
71
71
|
classAttr: { html: "marko/runtime/html/helpers/class-attr" },
|
|
@@ -76,31 +76,31 @@ const helpers = {
|
|
|
76
76
|
dataMarko: { html: "marko/runtime/html/helpers/data-marko" },
|
|
77
77
|
bindComponent: "marko/runtime/helpers/bind-component",
|
|
78
78
|
defineComponent: {
|
|
79
|
-
vdom: "marko/runtime/components/defineComponent"
|
|
79
|
+
vdom: "marko/runtime/components/defineComponent",
|
|
80
80
|
},
|
|
81
81
|
"defineComponent-legacy": {
|
|
82
82
|
vdom: "marko/runtime/components/legacy/defineComponent-legacy",
|
|
83
|
-
html: "marko/runtime/helpers/noop"
|
|
83
|
+
html: "marko/runtime/helpers/noop",
|
|
84
84
|
},
|
|
85
85
|
"defineWidget-legacy": "marko/runtime/components/legacy/defineWidget-legacy",
|
|
86
86
|
dynamicTag: "marko/runtime/helpers/dynamic-tag",
|
|
87
87
|
escapeXml: {
|
|
88
88
|
html: {
|
|
89
89
|
module: "marko/runtime/html/helpers/escape-xml",
|
|
90
|
-
method: "x"
|
|
91
|
-
}
|
|
90
|
+
method: "x",
|
|
91
|
+
},
|
|
92
92
|
},
|
|
93
93
|
escapeDoubleQuoteAttrValue: {
|
|
94
94
|
html: {
|
|
95
95
|
module: "marko/runtime/html/helpers/escape-quotes",
|
|
96
|
-
method: "d"
|
|
97
|
-
}
|
|
96
|
+
method: "d",
|
|
97
|
+
},
|
|
98
98
|
},
|
|
99
99
|
escapeScript: {
|
|
100
|
-
html: "marko/runtime/html/helpers/escape-script-placeholder"
|
|
100
|
+
html: "marko/runtime/html/helpers/escape-script-placeholder",
|
|
101
101
|
},
|
|
102
102
|
escapeStyle: {
|
|
103
|
-
html: "marko/runtime/html/helpers/escape-style-placeholder"
|
|
103
|
+
html: "marko/runtime/html/helpers/escape-style-placeholder",
|
|
104
104
|
},
|
|
105
105
|
forOf: "marko/runtime/helpers/for-of",
|
|
106
106
|
forIn: "marko/runtime/helpers/for-in",
|
|
@@ -115,13 +115,13 @@ const helpers = {
|
|
|
115
115
|
rendererLegacy: "marko/runtime/components/legacy/renderer-legacy",
|
|
116
116
|
registerComponent: {
|
|
117
117
|
module: "marko/runtime/components/registry",
|
|
118
|
-
method: "r"
|
|
118
|
+
method: "r",
|
|
119
119
|
},
|
|
120
120
|
str: "marko/runtime/helpers/to-string",
|
|
121
121
|
styleValue: "marko/runtime/helpers/style-value",
|
|
122
122
|
styleAttr: {
|
|
123
|
-
html: "marko/runtime/html/helpers/style-attr"
|
|
124
|
-
}
|
|
123
|
+
html: "marko/runtime/html/helpers/style-attr",
|
|
124
|
+
},
|
|
125
125
|
};
|
|
126
126
|
|
|
127
127
|
class CompileContext extends EventEmitter {
|
|
@@ -268,7 +268,7 @@ class CompileContext extends EventEmitter {
|
|
|
268
268
|
return {
|
|
269
269
|
pop: () => {
|
|
270
270
|
this.popData(key);
|
|
271
|
-
}
|
|
271
|
+
},
|
|
272
272
|
};
|
|
273
273
|
}
|
|
274
274
|
|
|
@@ -337,7 +337,7 @@ class CompileContext extends EventEmitter {
|
|
|
337
337
|
node,
|
|
338
338
|
message,
|
|
339
339
|
code,
|
|
340
|
-
pos
|
|
340
|
+
pos,
|
|
341
341
|
};
|
|
342
342
|
} else if (typeof errorInfo === "string") {
|
|
343
343
|
let message = arguments[0];
|
|
@@ -347,7 +347,7 @@ class CompileContext extends EventEmitter {
|
|
|
347
347
|
errorInfo = {
|
|
348
348
|
message,
|
|
349
349
|
code,
|
|
350
|
-
pos
|
|
350
|
+
pos,
|
|
351
351
|
};
|
|
352
352
|
}
|
|
353
353
|
|
|
@@ -489,7 +489,7 @@ class CompileContext extends EventEmitter {
|
|
|
489
489
|
message:
|
|
490
490
|
"Unrecognized tag: " +
|
|
491
491
|
tagName +
|
|
492
|
-
" - More details: https://github.com/marko-js/marko/wiki/Error:-Unrecognized-Tag"
|
|
492
|
+
" - More details: https://github.com/marko-js/marko/wiki/Error:-Unrecognized-Tag",
|
|
493
493
|
});
|
|
494
494
|
}
|
|
495
495
|
|
|
@@ -510,9 +510,9 @@ class CompileContext extends EventEmitter {
|
|
|
510
510
|
} else if (typeof attributes === "object") {
|
|
511
511
|
if (!Array.isArray(attributes)) {
|
|
512
512
|
attributes = elDef.attributes = Object.keys(attributes).map(
|
|
513
|
-
attrName => {
|
|
513
|
+
(attrName) => {
|
|
514
514
|
var attrDef = {
|
|
515
|
-
name: attrName
|
|
515
|
+
name: attrName,
|
|
516
516
|
};
|
|
517
517
|
|
|
518
518
|
var val = attributes[attrName];
|
|
@@ -576,7 +576,7 @@ class CompileContext extends EventEmitter {
|
|
|
576
576
|
// may be a macro that gets registered later
|
|
577
577
|
this.unrecognizedTags.push({
|
|
578
578
|
node: elNode,
|
|
579
|
-
tagName: tagName
|
|
579
|
+
tagName: tagName,
|
|
580
580
|
});
|
|
581
581
|
}
|
|
582
582
|
}
|
|
@@ -620,7 +620,7 @@ class CompileContext extends EventEmitter {
|
|
|
620
620
|
var foundAttrs = {};
|
|
621
621
|
|
|
622
622
|
// Validate the attributes
|
|
623
|
-
attributes.forEach(attr => {
|
|
623
|
+
attributes.forEach((attr) => {
|
|
624
624
|
let attrName = attr.name;
|
|
625
625
|
if (!attrName) {
|
|
626
626
|
// Attribute will be name for placeholder attributes. For example: <div ${data.myAttrs}>
|
|
@@ -644,7 +644,7 @@ class CompileContext extends EventEmitter {
|
|
|
644
644
|
getTaglibPath(tagDef.taglibId) +
|
|
645
645
|
'" does not support attribute "' +
|
|
646
646
|
attrName +
|
|
647
|
-
'"'
|
|
647
|
+
'"',
|
|
648
648
|
});
|
|
649
649
|
}
|
|
650
650
|
return;
|
|
@@ -665,7 +665,7 @@ class CompileContext extends EventEmitter {
|
|
|
665
665
|
// Add default values for any attributes. If an attribute has a declared
|
|
666
666
|
// default value and the attribute was not found on the element
|
|
667
667
|
// then add the attribute with the specified default value
|
|
668
|
-
tagDef.forEachAttribute(attrDef => {
|
|
668
|
+
tagDef.forEachAttribute((attrDef) => {
|
|
669
669
|
var attrName = attrDef.name;
|
|
670
670
|
|
|
671
671
|
if (
|
|
@@ -674,7 +674,7 @@ class CompileContext extends EventEmitter {
|
|
|
674
674
|
) {
|
|
675
675
|
attributes.push({
|
|
676
676
|
name: attrName,
|
|
677
|
-
value: builder.literal(attrDef.defaultValue)
|
|
677
|
+
value: builder.literal(attrDef.defaultValue),
|
|
678
678
|
});
|
|
679
679
|
} else if (attrDef.required === true) {
|
|
680
680
|
// TODO Only throw an error if there is no data argument provided (just HTML attributes)
|
|
@@ -688,7 +688,7 @@ class CompileContext extends EventEmitter {
|
|
|
688
688
|
tagName +
|
|
689
689
|
'" in taglib "' +
|
|
690
690
|
getTaglibPath(tagDef.taglibId) +
|
|
691
|
-
'".'
|
|
691
|
+
'".',
|
|
692
692
|
});
|
|
693
693
|
}
|
|
694
694
|
}
|
|
@@ -744,7 +744,7 @@ class CompileContext extends EventEmitter {
|
|
|
744
744
|
builder.literal(relativePath)
|
|
745
745
|
);
|
|
746
746
|
let loadFunctionCall = builder.functionCall(this.helper("loadTemplate"), [
|
|
747
|
-
loadTemplateArg
|
|
747
|
+
loadTemplateArg,
|
|
748
748
|
]);
|
|
749
749
|
templateVar = this.addStaticVar(varName, loadFunctionCall);
|
|
750
750
|
}
|
|
@@ -773,7 +773,7 @@ class CompileContext extends EventEmitter {
|
|
|
773
773
|
this.meta[key] = [value];
|
|
774
774
|
} else if (
|
|
775
775
|
!unique ||
|
|
776
|
-
!property.some(e => JSON.stringify(e) === JSON.stringify(value))
|
|
776
|
+
!property.some((e) => JSON.stringify(e) === JSON.stringify(value))
|
|
777
777
|
) {
|
|
778
778
|
property.push(value);
|
|
779
779
|
}
|
|
@@ -852,7 +852,7 @@ class CompileContext extends EventEmitter {
|
|
|
852
852
|
let staticNodes = [];
|
|
853
853
|
let staticVars = this.getStaticVars();
|
|
854
854
|
|
|
855
|
-
let staticVarNodes = Object.keys(staticVars).map(varName => {
|
|
855
|
+
let staticVarNodes = Object.keys(staticVars).map((varName) => {
|
|
856
856
|
var varInit = staticVars[varName];
|
|
857
857
|
return builder.variableDeclarator(varName, varInit);
|
|
858
858
|
});
|
|
@@ -953,7 +953,7 @@ class CompileContext extends EventEmitter {
|
|
|
953
953
|
|
|
954
954
|
optimize(rootNode) {
|
|
955
955
|
if (this._optimizers) {
|
|
956
|
-
this._optimizers.forEach(optimizer => {
|
|
956
|
+
this._optimizers.forEach((optimizer) => {
|
|
957
957
|
optimizer.optimize(rootNode, this);
|
|
958
958
|
});
|
|
959
959
|
}
|
|
@@ -978,7 +978,7 @@ class CompileContext extends EventEmitter {
|
|
|
978
978
|
|
|
979
979
|
CompileContext.prototype.util = {
|
|
980
980
|
isValidJavaScriptIdentifier: require("./util/isValidJavaScriptIdentifier"),
|
|
981
|
-
isJavaScriptReservedWord: require("./util/isJavaScriptReservedWord")
|
|
981
|
+
isJavaScriptReservedWord: require("./util/isJavaScriptReservedWord"),
|
|
982
982
|
};
|
|
983
983
|
|
|
984
984
|
module.exports = CompileContext;
|
package/src/compiler/Compiler.js
CHANGED
|
@@ -58,7 +58,7 @@ function transformTreeHelper(node, context) {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
function transformTree(rootNode, context) {
|
|
61
|
-
context.taglibLookup.forEachTemplateTransformer(transformer => {
|
|
61
|
+
context.taglibLookup.forEachTemplateTransformer((transformer) => {
|
|
62
62
|
var transformFunc = transformer.getFunc();
|
|
63
63
|
rootNode = transformFunc(rootNode, context) || rootNode;
|
|
64
64
|
});
|
|
@@ -111,7 +111,7 @@ class CompiledTemplate {
|
|
|
111
111
|
var meta = this.context.meta;
|
|
112
112
|
if (meta) {
|
|
113
113
|
var root = path.dirname(this.filename);
|
|
114
|
-
return (meta.deps || []).map(dep => resolveDep(dep, root));
|
|
114
|
+
return (meta.deps || []).map((dep) => resolveDep(dep, root));
|
|
115
115
|
} else {
|
|
116
116
|
return [];
|
|
117
117
|
}
|
|
@@ -151,7 +151,7 @@ class Compiler {
|
|
|
151
151
|
|
|
152
152
|
// STAGE 1: Parse the template to produce the initial AST
|
|
153
153
|
var ast = this.parser.parse(src, context, {
|
|
154
|
-
migrate: true && !process.env.MARKO_NO_MIGRATE
|
|
154
|
+
migrate: true && !process.env.MARKO_NO_MIGRATE,
|
|
155
155
|
});
|
|
156
156
|
// console.log('ROOT', JSON.stringify(ast, null, 2));
|
|
157
157
|
|
|
@@ -23,11 +23,11 @@ class HtmlJsParser {
|
|
|
23
23
|
onString(event) {
|
|
24
24
|
if (!event.isStringLiteral) {
|
|
25
25
|
let value = "";
|
|
26
|
-
event.stringParts.forEach(part => {
|
|
26
|
+
event.stringParts.forEach((part) => {
|
|
27
27
|
if (part.type === "placeholder") {
|
|
28
28
|
value += "${" + part.value + "}";
|
|
29
29
|
} else {
|
|
30
|
-
value += part.replace(/`|\${/g, match => "\\" + match);
|
|
30
|
+
value += part.replace(/`|\${/g, (match) => "\\" + match);
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
33
|
event.value = "$nonstandard`" + value + "`";
|
|
@@ -90,7 +90,7 @@ class HtmlJsParser {
|
|
|
90
90
|
|
|
91
91
|
onError(event) {
|
|
92
92
|
handlers.handleError(event);
|
|
93
|
-
}
|
|
93
|
+
},
|
|
94
94
|
};
|
|
95
95
|
|
|
96
96
|
var mergedOptions = Object.assign({}, this.defaultOptions, options);
|
|
@@ -98,7 +98,7 @@ class HtmlJsParser {
|
|
|
98
98
|
ignorePlaceholders: mergedOptions.ignorePlaceholders,
|
|
99
99
|
isOpenTagOnly: function (tagName) {
|
|
100
100
|
return handlers.isOpenTagOnly(tagName);
|
|
101
|
-
}
|
|
101
|
+
},
|
|
102
102
|
}));
|
|
103
103
|
parser.parse(src, filename);
|
|
104
104
|
}
|
package/src/compiler/Migrator.js
CHANGED
|
@@ -13,7 +13,7 @@ function migrateNode(node, context) {
|
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
context.taglibLookup.forEachTagMigrator(node, migration => {
|
|
16
|
+
context.taglibLookup.forEachTagMigrator(node, (migration) => {
|
|
17
17
|
// Check to make sure a migration of a certain type is only applied once to a node
|
|
18
18
|
if (node.isTransformerApplied(migration)) {
|
|
19
19
|
return;
|
|
@@ -61,7 +61,7 @@ function migrateTreeHelper(node, context) {
|
|
|
61
61
|
function migrateTree(ast, context) {
|
|
62
62
|
// TODO: Consider moving this into the loop below so that root level migrations
|
|
63
63
|
// are also run on new nodes.
|
|
64
|
-
context.taglibLookup.forEachTemplateMigrator(migration => {
|
|
64
|
+
context.taglibLookup.forEachTemplateMigrator((migration) => {
|
|
65
65
|
migration(ast, context);
|
|
66
66
|
});
|
|
67
67
|
|
|
@@ -10,7 +10,7 @@ function isIEConditionalComment(comment) {
|
|
|
10
10
|
|
|
11
11
|
function mergeShorthandClassNames(el, shorthandClassNames, context) {
|
|
12
12
|
var builder = context.builder;
|
|
13
|
-
let classNames = shorthandClassNames.map(className => {
|
|
13
|
+
let classNames = shorthandClassNames.map((className) => {
|
|
14
14
|
return typeof className == "string"
|
|
15
15
|
? builder.literal(className)
|
|
16
16
|
: className;
|
|
@@ -45,7 +45,7 @@ function mergeShorthandClassNames(el, shorthandClassNames, context) {
|
|
|
45
45
|
el.setAttributeValue(
|
|
46
46
|
"class",
|
|
47
47
|
builder.functionCall(context.helper("classValue"), [
|
|
48
|
-
builder.literal(finalClassNames)
|
|
48
|
+
builder.literal(finalClassNames),
|
|
49
49
|
])
|
|
50
50
|
);
|
|
51
51
|
}
|
|
@@ -93,7 +93,7 @@ class Normalizer {
|
|
|
93
93
|
if (newNode !== node) {
|
|
94
94
|
return newNode;
|
|
95
95
|
}
|
|
96
|
-
}
|
|
96
|
+
},
|
|
97
97
|
})
|
|
98
98
|
.walk(rootNode);
|
|
99
99
|
|
|
@@ -110,7 +110,7 @@ class Normalizer {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
if (elNode.tagName === "marko-migration-flags") {
|
|
113
|
-
elNode.attributes.forEach(attr => {
|
|
113
|
+
elNode.attributes.forEach((attr) => {
|
|
114
114
|
context.setFlag(attr.name);
|
|
115
115
|
});
|
|
116
116
|
elNode.detach();
|
|
@@ -147,7 +147,7 @@ class Normalizer {
|
|
|
147
147
|
openTagOnly: elNode.openTagOnly,
|
|
148
148
|
selfClosed: elNode.selfClosed,
|
|
149
149
|
pos: elNode.pos,
|
|
150
|
-
attributes: elNode.attributes
|
|
150
|
+
attributes: elNode.attributes,
|
|
151
151
|
});
|
|
152
152
|
|
|
153
153
|
newNode.pos = elNode.pos;
|
package/src/compiler/Parser.js
CHANGED
|
@@ -10,7 +10,7 @@ var COMPILER_ATTRIBUTE_HANDLERS = {
|
|
|
10
10
|
},
|
|
11
11
|
"preserve-comments": function (attr, context) {
|
|
12
12
|
context.setPreserveComments(true);
|
|
13
|
-
}
|
|
13
|
+
},
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
function getSimplifiedValue(node) {
|
|
@@ -41,7 +41,7 @@ function getParserStateForTag(parser, el, tagDef) {
|
|
|
41
41
|
parser.context.addError({
|
|
42
42
|
message:
|
|
43
43
|
'Value for "marko-body" should be one of the following: "static-text", "parsed-text", "html"',
|
|
44
|
-
code: "ERR_INVALID_ATTR"
|
|
44
|
+
code: "ERR_INVALID_ATTR",
|
|
45
45
|
});
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
@@ -100,7 +100,7 @@ class Parser {
|
|
|
100
100
|
this.context = context;
|
|
101
101
|
|
|
102
102
|
this.stack.push({
|
|
103
|
-
node: rootNode
|
|
103
|
+
node: rootNode,
|
|
104
104
|
});
|
|
105
105
|
|
|
106
106
|
this.parserImpl.parse(src, this, context.filename, mergedOptions);
|
|
@@ -177,7 +177,7 @@ class Parser {
|
|
|
177
177
|
'". Allowed: ' +
|
|
178
178
|
Object.keys(COMPILER_ATTRIBUTE_HANDLERS).join(", "),
|
|
179
179
|
pos: el.pos,
|
|
180
|
-
node: el
|
|
180
|
+
node: el,
|
|
181
181
|
});
|
|
182
182
|
return;
|
|
183
183
|
}
|
|
@@ -205,7 +205,7 @@ class Parser {
|
|
|
205
205
|
openTagOnly: el.openTagOnly === true,
|
|
206
206
|
selfClosed: el.selfClosed === true,
|
|
207
207
|
pos: el.pos,
|
|
208
|
-
attributes: parsedAttributes
|
|
208
|
+
attributes: parsedAttributes,
|
|
209
209
|
};
|
|
210
210
|
|
|
211
211
|
var node = builder.htmlElement(elDef);
|
|
@@ -213,7 +213,7 @@ class Parser {
|
|
|
213
213
|
node.tagDef = tagDef;
|
|
214
214
|
|
|
215
215
|
if (attributeParseErrors && attributeParseErrors.length) {
|
|
216
|
-
attributeParseErrors.forEach(e => {
|
|
216
|
+
attributeParseErrors.forEach((e) => {
|
|
217
217
|
context.addError(node, e);
|
|
218
218
|
});
|
|
219
219
|
}
|
|
@@ -224,7 +224,7 @@ class Parser {
|
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
if (el.shorthandClassNames) {
|
|
227
|
-
node.rawShorthandClassNames = el.shorthandClassNames.map(className => {
|
|
227
|
+
node.rawShorthandClassNames = el.shorthandClassNames.map((className) => {
|
|
228
228
|
let parsed = builder.parseExpression(className.value);
|
|
229
229
|
return getSimplifiedValue(parsed);
|
|
230
230
|
});
|
|
@@ -238,7 +238,7 @@ class Parser {
|
|
|
238
238
|
|
|
239
239
|
this.stack.push({
|
|
240
240
|
node: node,
|
|
241
|
-
tag: null
|
|
241
|
+
tag: null,
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
244
|
|
|
@@ -249,7 +249,7 @@ class Parser {
|
|
|
249
249
|
// <div class="foo"> -> "div class=foo"
|
|
250
250
|
var parsedAttributes = [];
|
|
251
251
|
|
|
252
|
-
attributes.forEach(attr => {
|
|
252
|
+
attributes.forEach((attr) => {
|
|
253
253
|
var attrName = attr.name;
|
|
254
254
|
var attrRawValue = attr.value;
|
|
255
255
|
var attrSpread;
|
|
@@ -296,7 +296,7 @@ class Parser {
|
|
|
296
296
|
var attrDef = {
|
|
297
297
|
name: attrName,
|
|
298
298
|
value: attrValue,
|
|
299
|
-
rawValue: attrRawValue
|
|
299
|
+
rawValue: attrRawValue,
|
|
300
300
|
};
|
|
301
301
|
|
|
302
302
|
if (attr.argument) {
|
|
@@ -369,7 +369,7 @@ class Parser {
|
|
|
369
369
|
message: event.message,
|
|
370
370
|
code: event.code,
|
|
371
371
|
pos: event.pos,
|
|
372
|
-
endPos: event.endPos
|
|
372
|
+
endPos: event.endPos,
|
|
373
373
|
});
|
|
374
374
|
}
|
|
375
375
|
|
package/src/compiler/Walker.js
CHANGED