Skip to content

Commit d13a4e9

Browse files
authored
Merge c97e639 into 08f6f39
2 parents 08f6f39 + c97e639 commit d13a4e9

File tree

232 files changed

+1252
-1969
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

232 files changed

+1252
-1969
lines changed

src/compiler/CompileContext.js

Lines changed: 60 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -56,62 +56,74 @@ function requireResolve(builder, path) {
5656
}
5757

5858
const helpers = {
59-
assign: { module: "marko/runtime/helper-assign" },
60-
attr: "a",
61-
attrs: "as",
62-
mergeAttrs: "am",
63-
classAttr: "ca",
64-
classList: "cl",
65-
const: "const",
66-
createElement: "e",
59+
assign: "marko/runtime/helpers/assign",
60+
merge: "marko/runtime/helpers/merge",
61+
attr: {
62+
html: "marko/runtime/html/helpers/attr",
63+
vdom: "marko/runtime/vdom/helpers/attr"
64+
},
65+
attrs: {
66+
html: "marko/runtime/html/helpers/attrs",
67+
vdom: "marko/runtime/vdom/helpers/attrs"
68+
},
69+
mergeAttrs: { html: "marko/runtime/html/helpers/merge-attrs" },
70+
classAttr: { html: "marko/runtime/html/helpers/class-attr" },
71+
classValue: "marko/runtime/helpers/class-value",
72+
const: { vdom: "marko/runtime/vdom/helpers/const" },
73+
createElement: { vdom: "marko/runtime/vdom/helpers/v-element" },
74+
createText: { vdom: "marko/runtime/vdom/helpers/v-text" },
6775
defineComponent: {
68-
module: "marko/runtime/components/helpers",
69-
method: "c"
76+
vdom: "marko/runtime/components/defineComponent"
7077
},
7178
"defineComponent-legacy": {
72-
module: "marko/runtime/components/legacy/helpers",
73-
method: "c"
79+
vdom: "marko/runtime/components/legacy/defineComponent-legacy",
80+
html: "marko/runtime/helpers/noop"
7481
},
7582
"defineWidget-legacy": {
76-
module: "marko/runtime/components/legacy/helpers",
77-
method: "w"
83+
html: "marko/runtime/components/legacy/defineWidget-legacy",
84+
vdom: "marko/runtime/components/legacy/defineWidget-legacy-browser"
85+
},
86+
dynamicTag: "marko/runtime/helpers/dynamic-tag",
87+
escapeXml: {
88+
html: {
89+
module: "marko/runtime/html/helpers/escape-xml",
90+
method: "x"
91+
}
7892
},
79-
dynamicTag: "d",
80-
escapeXml: "x",
81-
escapeXmlAttr: "xa",
82-
escapeScript: "xs",
83-
escapeStyle: "xc",
84-
forEach: "f",
85-
forEachProp: { module: "marko/runtime/helper-forEachProperty" },
86-
forRange: { module: "marko/runtime/helper-forRange" },
87-
getWidgetFromOut: {
88-
module: "marko/runtime/components/legacy/helper-getWidgetFromOut"
93+
escapeDoubleQuoteAttrValue: {
94+
html: {
95+
module: "marko/runtime/html/helpers/escape-xml",
96+
method: "d"
97+
}
8998
},
90-
include: "i",
91-
loadNestedTag: { module: "marko/runtime/helper-loadNestedTag" },
92-
loadTag: "t",
93-
loadTemplate: { module: "marko/runtime/helper-loadTemplate" },
94-
mergeNestedTagsHelper: { module: "marko/runtime/helper-mergeNestedTags" },
95-
merge: { module: "marko/runtime/helper-merge" },
96-
propsForPreviousNode: "p",
97-
renderer: {
98-
module: "marko/runtime/components/helpers",
99-
method: "r"
99+
escapeScript: {
100+
html: "marko/runtime/html/helpers/escape-script-placeholder"
100101
},
101-
rendererLegacy: {
102-
module: "marko/runtime/components/legacy/helpers",
103-
method: "r"
102+
escapeStyle: {
103+
html: "marko/runtime/html/helpers/escape-style-placeholder"
104104
},
105+
forOf: "marko/runtime/helpers/for-of",
106+
forIn: "marko/runtime/helpers/for-in",
107+
forRange: "marko/runtime/helpers/for-range",
108+
getWidgetFromOut: "marko/runtime/components/legacy/helper-getWidgetFromOut",
109+
loadNestedTag: "marko/runtime/helpers/load-nested-tag",
110+
loadTag: "marko/runtime/helpers/load-tag",
111+
loadTemplate: "marko/runtime/helpers/load-template",
112+
mergeNestedTagsHelper: "marko/runtime/helpers/merge-nested-tags",
113+
propsForPreviousNode: { html: "marko/runtime/html/helpers/props-script" },
114+
renderer: "marko/runtime/components/renderer",
115+
rendererLegacy: "marko/runtime/components/legacy/renderer-legacy",
105116
registerComponent: {
106-
module: "marko/runtime/components/helpers",
107-
method: "rc"
117+
vdom: {
118+
module: "marko/runtime/components/registry-browser",
119+
method: "r"
120+
}
108121
},
109-
str: "s",
122+
str: "marko/runtime/helpers/to-string",
123+
styleValue: "marko/runtime/helpers/style-value",
110124
styleAttr: {
111-
vdom: { module: "marko/runtime/vdom/helper-styleAttr" },
112-
html: "sa"
113-
},
114-
createText: "t"
125+
html: "marko/runtime/html/helpers/style-attr"
126+
}
115127
};
116128

117129
class CompileContext extends EventEmitter {
@@ -897,17 +909,10 @@ class CompileContext extends EventEmitter {
897909
}
898910

899911
if (typeof helperInfo === "string") {
900-
let methodName = helperInfo;
901-
var methodIdentifier = this.builder.identifier(methodName);
902-
903-
helperIdentifier = this.addStaticVar(
904-
"marko_" + name,
905-
this.builder.memberExpression(
906-
this.helpersIdentifier,
907-
methodIdentifier
908-
)
909-
);
910-
} else if (helperInfo && helperInfo.module) {
912+
helperInfo = { module: helperInfo };
913+
}
914+
915+
if (helperInfo && helperInfo.module) {
911916
if (helperInfo.method) {
912917
let moduleIdentifier = this.importModule(
913918
"marko_" + helperInfo.module,

src/compiler/Normalizer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function mergeShorthandClassNames(el, shorthandClassNames, context) {
4444
} else {
4545
el.setAttributeValue(
4646
"class",
47-
builder.functionCall(context.helper("classList"), [
47+
builder.functionCall(context.helper("classValue"), [
4848
builder.literal(finalClassNames)
4949
])
5050
);

src/compiler/ast/ForEach.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ForEach extends Node {
1515
var context = codegen.context;
1616
var builder = codegen.builder;
1717

18-
return builder.functionCall(context.helper("forEach"), [
18+
return builder.functionCall(context.helper("forOf"), [
1919
this.of,
2020
builder.functionDeclaration(null, this.params, this.body)
2121
]);

src/compiler/ast/ForEachProp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ForEachProp extends Node {
1818
var body = this.body;
1919
var builder = codegen.builder;
2020

21-
return builder.functionCall(context.helper("forEachProp"), [
21+
return builder.functionCall(context.helper("forIn"), [
2222
inExpression,
2323
builder.functionDeclaration(null, params, body)
2424
]);

src/compiler/ast/HtmlAttribute/html/generateCode.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
"use strict";
22

3-
var runtimeHtmlHelpers = require("../../../../runtime/html/helpers");
4-
var attr = runtimeHtmlHelpers.a;
5-
var escapeXmlAttr = runtimeHtmlHelpers.xa;
3+
var attr = require("../../../../runtime/html/helpers/attr");
4+
var escapeXmlAttr = require("../../../../runtime/html/helpers/escape-xml").d;
65

76
function isStringLiteral(node) {
87
return node.type === "Literal" && typeof node.value === "string";
@@ -86,7 +85,7 @@ function generateCodeForExpressionAttr(name, value, escape, codegen) {
8685
} else {
8786
if (escape !== false) {
8887
part = builder.functionCall(
89-
context.helper("escapeXmlAttr"),
88+
context.helper("escapeDoubleQuoteAttrValue"),
9089
[part]
9190
);
9291
}

src/compiler/ast/HtmlAttribute/vdom/generateCode.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ module.exports = function generateCode(node, codegen, vdomUtil) {
2424
}
2525
} else {
2626
if (name === "class") {
27-
node.value = builder.functionCall(context.helper("classAttr"), [
28-
attrValue
29-
]);
27+
node.value = builder.functionCall(
28+
context.helper("classValue"),
29+
[attrValue]
30+
);
3031
} else if (name === "style") {
31-
node.value = builder.functionCall(context.helper("styleAttr"), [
32-
attrValue
33-
]);
32+
node.value = builder.functionCall(
33+
context.helper("styleValue"),
34+
[attrValue]
35+
);
3436
}
3537
}
3638
}

src/compiler/ast/Text/html/generateCode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22

3-
var escapeXml = require("../../../../runtime/html/helpers").x;
3+
var escapeXml = require("../../../../runtime/html/helpers/escape-xml").x;
44
var Literal = require("../../Literal");
55

66
module.exports = function(node, codegen) {

src/core-tags/components/TransformHelper/convertToComponent.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ module.exports = function handleComponentBind(options) {
2222
let rootNodes = options.rootNodes;
2323
let isLegacyInnerBind = options.isLegacyInnerBind;
2424
var isImplicitComponent = options.isImplicitComponent === true;
25+
var isBrowserTarget = context.outputType === "vdom";
2526
var hasTagParams = context.isFlagSet("hasTagParams");
2627
var isSplit = false;
2728

@@ -137,7 +138,7 @@ module.exports = function handleComponentBind(options) {
137138

138139
var defineComponentHelper;
139140

140-
if (!isSplit && !isLegacyComponent) {
141+
if (!isSplit && !isLegacyComponent && isBrowserTarget) {
141142
defineComponentHelper = this.context.helper("defineComponent");
142143
}
143144

@@ -180,7 +181,7 @@ module.exports = function handleComponentBind(options) {
180181
)
181182
);
182183

183-
if (!isSplit && !isLegacyComponent) {
184+
if (!isSplit && !isLegacyComponent && isBrowserTarget) {
184185
nodes.push(
185186
builder.assignment(
186187
builder.memberExpression(

src/runtime/components/helpers-browser.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/runtime/components/helpers.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)