@marko/translator-default 5.31.14 → 5.31.16
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.js +2 -4
- package/dist/tag/attribute/modifiers/no-update.js +2 -15
- package/dist/tag/attribute-tag.js +149 -151
- package/dist/tag/dynamic-tag.js +9 -2
- package/dist/tag/index.js +6 -2
- package/dist/tag/native-tag[html]/index.js +9 -2
- package/dist/tag/native-tag[vdom]/index.js +9 -2
- package/dist/tag/util.js +61 -36
- package/package.json +3 -3
package/dist/index.js
CHANGED
@@ -472,10 +472,9 @@ function getRuntimeEntryFiles(output, optimize) {
|
|
472
472
|
`${base}runtime/helpers/assign.js`,
|
473
473
|
`${base}runtime/helpers/class-value.js`,
|
474
474
|
`${base}runtime/helpers/dynamic-tag.js`,
|
475
|
-
`${base}runtime/helpers/
|
475
|
+
`${base}runtime/helpers/attr-tag.js`,
|
476
476
|
`${base}runtime/helpers/merge.js`,
|
477
477
|
`${base}runtime/helpers/repeatable.js`,
|
478
|
-
`${base}runtime/helpers/self-iterator.js`,
|
479
478
|
`${base}runtime/helpers/render-tag.js`,
|
480
479
|
`${base}runtime/helpers/style-value.js`,
|
481
480
|
`${base}runtime/helpers/to-string.js`,
|
@@ -505,8 +504,7 @@ function getRuntimeEntryFiles(output, optimize) {
|
|
505
504
|
`${base}runtime/vdom/index.js`,
|
506
505
|
`${base}runtime/vdom/hot-reload.js`,
|
507
506
|
`${base}runtime/vdom/helpers/attrs.js`,
|
508
|
-
`${base}runtime/vdom/helpers/const-element.js
|
509
|
-
`${base}runtime/vdom/preserve-attrs.js`])];
|
507
|
+
`${base}runtime/vdom/helpers/const-element.js`])];
|
510
508
|
|
511
509
|
|
512
510
|
}
|
@@ -1,25 +1,12 @@
|
|
1
|
-
"use strict";exports.__esModule = true;exports.default = void 0;
|
2
|
-
|
3
|
-
const hasMonkeyPatch = new WeakSet();
|
4
|
-
|
5
|
-
/**
|
1
|
+
"use strict";exports.__esModule = true;exports.default = void 0; /**
|
6
2
|
* Does nothing in html mode.
|
7
3
|
*/var _default = exports.default =
|
8
4
|
{
|
9
5
|
exit(tag, attr) {
|
10
|
-
const {
|
11
|
-
node,
|
12
|
-
hub: { file }
|
13
|
-
} = tag;
|
14
|
-
const isVDOM = file.markoOpts.output !== "html";
|
6
|
+
const { node } = tag;
|
15
7
|
|
16
8
|
if (!node.preserveAttrs) {
|
17
9
|
node.preserveAttrs = [];
|
18
|
-
|
19
|
-
if (isVDOM && !hasMonkeyPatch.has(file)) {
|
20
|
-
hasMonkeyPatch.add(file);
|
21
|
-
(0, _babelUtils.importDefault)(file, "marko/src/runtime/vdom/preserve-attrs.js");
|
22
|
-
}
|
23
10
|
}
|
24
11
|
|
25
12
|
node.preserveAttrs.push(attr.node.name);
|
@@ -1,4 +1,5 @@
|
|
1
|
-
"use strict";
|
1
|
+
"use strict";exports.__esModule = true;exports.analyzeAttributeTags = analyzeAttributeTags;exports.default = translateAttributeTag;var _babelUtils = require("@marko/babel-utils");
|
2
|
+
|
2
3
|
|
3
4
|
|
4
5
|
|
@@ -7,182 +8,179 @@
|
|
7
8
|
|
8
9
|
|
9
10
|
var _compiler = require("@marko/compiler");
|
10
|
-
var _withPreviousLocation = _interopRequireDefault(require("../util/with-previous-location"));
|
11
11
|
var _util = require("./util");
|
12
12
|
|
13
|
-
const
|
14
|
-
const
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
const
|
22
|
-
const
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
13
|
+
const contentTypeCache = new WeakMap();
|
14
|
+
const ContentType = {
|
15
|
+
attribute: 0,
|
16
|
+
render: 1,
|
17
|
+
mixed: 2
|
18
|
+
};
|
19
|
+
|
20
|
+
function analyzeAttributeTags(rootTag) {
|
21
|
+
const visit = [rootTag];
|
22
|
+
const parentTags = [rootTag];
|
23
|
+
let i = 0;
|
24
|
+
let attributeTags;
|
25
|
+
|
26
|
+
while (i < visit.length) {
|
27
|
+
const tag = visit[i++];
|
28
|
+
for (const child of tag.get("body").get("body")) {
|
29
|
+
if ((0, _babelUtils.isAttributeTag)(child)) {
|
30
|
+
(0, _babelUtils.assertNoArgs)(child);
|
31
|
+
const tagDef = (0, _babelUtils.getTagDef)(child) || {};
|
32
|
+
const name = (0, _babelUtils.getFullyResolvedTagName)(child);
|
33
|
+
let {
|
34
|
+
targetProperty = child.node.name.value.slice(1),
|
35
|
+
isRepeated = false
|
36
|
+
} = tagDef;
|
37
|
+
|
38
|
+
const preserveName =
|
39
|
+
tagDef.preserveName === true || tagDef.removeDashes === false;
|
40
|
+
|
41
|
+
if (!preserveName) {
|
42
|
+
targetProperty = removeDashes(targetProperty);
|
43
|
+
}
|
31
44
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
const attrTagMeta = (attributeTags ||= {})[name] ||= {
|
46
|
+
targetProperty,
|
47
|
+
isRepeated
|
48
|
+
};
|
49
|
+
|
50
|
+
(child.node.extra ||= {}).attributeTag = attrTagMeta;
|
51
|
+
|
52
|
+
const parentTag = (0, _babelUtils.findParentTag)(child);
|
53
|
+
const parentTagExtra = parentTag.node.extra ||= {};
|
54
|
+
parentTagExtra.hasAttributeTags = true;
|
55
|
+
parentTags.push(child);
|
56
|
+
visit.push(child);
|
57
|
+
} else if ((0, _babelUtils.isTransparentTag)(child)) {
|
58
|
+
switch (getContentType(child)) {
|
59
|
+
case ContentType.mixed:
|
60
|
+
throw child.buildCodeFrameError(
|
61
|
+
"Cannot mix @tags with other content when under a control flow."
|
62
|
+
);
|
63
|
+
case ContentType.attribute:
|
64
|
+
visit.push(child);
|
65
|
+
break;
|
66
|
+
case ContentType.render:
|
67
|
+
break;
|
49
68
|
}
|
50
69
|
}
|
51
70
|
}
|
52
|
-
} else {
|
53
|
-
const previousAttr = parentAttributes.find(
|
54
|
-
(attr) => attr.get("name").node === targetProperty
|
55
|
-
);
|
56
|
-
|
57
|
-
if (previousAttr) {
|
58
|
-
const previousValue = previousAttr.get("value").node;
|
59
|
-
if (_compiler.types.isObjectExpression(previousValue)) {
|
60
|
-
previousAttr.set(
|
61
|
-
"value",
|
62
|
-
_compiler.types.arrayExpression([previousValue, getAttrTagObject(tag)])
|
63
|
-
);
|
64
|
-
} else if (_compiler.types.isArrayExpression(previousAttr)) {
|
65
|
-
previousAttr.elements.push(getAttrTagObject(tag));
|
66
|
-
} else {
|
67
|
-
previousAttr.set(
|
68
|
-
"value",
|
69
|
-
_compiler.types.callExpression(
|
70
|
-
(0, _babelUtils.importDefault)(
|
71
|
-
tag.hub.file,
|
72
|
-
"marko/src/runtime/helpers/repeatable.js",
|
73
|
-
"marko_repeatable"
|
74
|
-
),
|
75
|
-
[previousValue, getAttrTagObject(tag)]
|
76
|
-
)
|
77
|
-
);
|
78
|
-
}
|
79
|
-
} else {
|
80
|
-
parentPath.pushContainer(
|
81
|
-
"attributes",
|
82
|
-
_compiler.types.markoAttribute(targetProperty, getAttrTagObject(tag))
|
83
|
-
);
|
84
|
-
}
|
85
|
-
|
86
|
-
tag.remove();
|
87
|
-
return;
|
88
71
|
}
|
89
72
|
|
90
|
-
|
73
|
+
if (attributeTags) {
|
74
|
+
(rootTag.node.extra ??= {}).attributeTags = attributeTags;
|
75
|
+
|
76
|
+
for (const parentTag of parentTags) {
|
77
|
+
if (getContentType(parentTag) === ContentType.mixed) {
|
78
|
+
// move all non scriptlet / attribute tag children to the end of the renderbody
|
79
|
+
const renderBody = [
|
80
|
+
_compiler.types.expressionStatement(_compiler.types.stringLiteral("END_ATTRIBUTE_TAGS"))];
|
81
|
+
|
82
|
+
const body = parentTag.get("body");
|
83
|
+
for (const child of body.get("body")) {
|
84
|
+
if (
|
85
|
+
child.isMarkoScriptlet() ||
|
86
|
+
(0, _babelUtils.isAttributeTag)(child) ||
|
87
|
+
(0, _babelUtils.isTransparentTag)(child) &&
|
88
|
+
getContentType(child) === ContentType.attribute)
|
89
|
+
{
|
90
|
+
continue;
|
91
|
+
}
|
92
|
+
|
93
|
+
renderBody.push(child.node);
|
94
|
+
child.remove();
|
95
|
+
}
|
91
96
|
|
92
|
-
|
93
|
-
|
97
|
+
body.node.body = body.node.body.concat(renderBody);
|
98
|
+
}
|
99
|
+
}
|
94
100
|
}
|
101
|
+
}
|
95
102
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
tag.
|
101
|
-
|
102
|
-
|
103
|
-
unshiftContainer(
|
104
|
-
"body",
|
105
|
-
_compiler.types.variableDeclaration(isRepeated ? "const" : "let", [
|
106
|
-
_compiler.types.variableDeclarator(
|
107
|
-
identifier,
|
108
|
-
isRepeated ? _compiler.types.arrayExpression([]) : _compiler.types.nullLiteral()
|
109
|
-
)]
|
110
|
-
)
|
111
|
-
);
|
112
|
-
parentPath.pushContainer(
|
113
|
-
"attributes",
|
114
|
-
_compiler.types.markoAttribute(targetProperty, identifier)
|
115
|
-
);
|
103
|
+
function translateAttributeTag(tag) {
|
104
|
+
const { node } = tag;
|
105
|
+
const meta = node.extra?.attributeTag;
|
106
|
+
if (!meta) {
|
107
|
+
throw tag.
|
108
|
+
get("name").
|
109
|
+
buildCodeFrameError("@tags must be nested within another element.");
|
116
110
|
}
|
117
111
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
} else {
|
131
|
-
tag.replaceWith(
|
132
|
-
(0, _withPreviousLocation.default)(
|
133
|
-
_compiler.types.expressionStatement(
|
134
|
-
_compiler.types.assignmentExpression(
|
135
|
-
"=",
|
136
|
-
identifier,
|
137
|
-
_compiler.types.callExpression(
|
138
|
-
(0, _babelUtils.importDefault)(
|
139
|
-
tag.hub.file,
|
140
|
-
"marko/src/runtime/helpers/repeatable.js",
|
141
|
-
"marko_repeatable"
|
142
|
-
),
|
143
|
-
[identifier, getAttrTagObject(tag)]
|
144
|
-
)
|
145
|
-
)
|
112
|
+
(0, _babelUtils.assertNoArgs)(tag);
|
113
|
+
|
114
|
+
tag.replaceWith(
|
115
|
+
_compiler.types.expressionStatement(
|
116
|
+
_compiler.types.callExpression(
|
117
|
+
(0, _babelUtils.importNamed)(
|
118
|
+
tag.hub.file,
|
119
|
+
"marko/src/runtime/helpers/attr-tag.js",
|
120
|
+
meta.isRepeated ? "r" : "a",
|
121
|
+
meta.isRepeated ?
|
122
|
+
"marko_repeated_attr_tag" :
|
123
|
+
"marko_repeatable_attr_tag"
|
146
124
|
),
|
147
|
-
|
125
|
+
[_compiler.types.stringLiteral(meta.targetProperty), getAttrTagObject(tag)]
|
148
126
|
)
|
149
|
-
)
|
150
|
-
|
127
|
+
)
|
128
|
+
);
|
151
129
|
}
|
152
130
|
|
153
131
|
function getAttrTagObject(tag) {
|
154
132
|
const attrs = (0, _util.getAttrs)(tag);
|
155
|
-
const iteratorProp = _compiler.types.objectProperty(
|
156
|
-
_compiler.types.memberExpression(_compiler.types.identifier("Symbol"), _compiler.types.identifier("iterator")),
|
157
|
-
(0, _babelUtils.importDefault)(
|
158
|
-
tag.hub.file,
|
159
|
-
"marko/src/runtime/helpers/self-iterator.js",
|
160
|
-
"marko_self_iterator"
|
161
|
-
),
|
162
|
-
true
|
163
|
-
);
|
164
133
|
|
165
134
|
if (_compiler.types.isNullLiteral(attrs)) {
|
166
|
-
return _compiler.types.objectExpression([
|
167
|
-
}
|
168
|
-
|
169
|
-
if (_compiler.types.isObjectExpression(attrs)) {
|
170
|
-
attrs.properties.push(iteratorProp);
|
171
|
-
return attrs;
|
135
|
+
return _compiler.types.objectExpression([]);
|
172
136
|
}
|
173
137
|
|
174
|
-
return
|
138
|
+
return attrs;
|
175
139
|
}
|
176
140
|
|
177
|
-
function
|
178
|
-
|
179
|
-
|
180
|
-
|
141
|
+
function getContentType(tag) {
|
142
|
+
const { node } = tag;
|
143
|
+
const cached = contentTypeCache.get(node);
|
144
|
+
if (cached !== undefined) return cached;
|
145
|
+
|
146
|
+
const body = tag.get("body").get("body");
|
147
|
+
let hasAttributeTag = false;
|
148
|
+
let hasRenderBody = false;
|
149
|
+
|
150
|
+
for (const child of body) {
|
151
|
+
if ((0, _babelUtils.isAttributeTag)(child)) {
|
152
|
+
hasAttributeTag = true;
|
153
|
+
} else if ((0, _babelUtils.isTransparentTag)(child)) {
|
154
|
+
switch (getContentType(child)) {
|
155
|
+
case ContentType.mixed:
|
156
|
+
contentTypeCache.set(node, ContentType.mixed);
|
157
|
+
return ContentType.mixed;
|
158
|
+
case ContentType.attribute:
|
159
|
+
hasAttributeTag = true;
|
160
|
+
break;
|
161
|
+
case ContentType.render:
|
162
|
+
hasRenderBody = true;
|
163
|
+
break;
|
164
|
+
}
|
165
|
+
} else if (!child.isMarkoScriptlet()) {
|
166
|
+
hasRenderBody = true;
|
167
|
+
}
|
181
168
|
|
182
|
-
|
183
|
-
|
184
|
-
|
169
|
+
if (hasAttributeTag && hasRenderBody) {
|
170
|
+
contentTypeCache.set(node, ContentType.mixed);
|
171
|
+
return ContentType.mixed;
|
172
|
+
}
|
185
173
|
}
|
186
174
|
|
187
|
-
|
175
|
+
const result = hasAttributeTag ? ContentType.attribute : ContentType.render;
|
176
|
+
contentTypeCache.set(node, result);
|
177
|
+
return result;
|
178
|
+
}
|
179
|
+
|
180
|
+
function removeDashes(str) {
|
181
|
+
return str.replace(/-([a-z])/g, matchToUpperCase);
|
182
|
+
}
|
183
|
+
|
184
|
+
function matchToUpperCase(_match, lower) {
|
185
|
+
return lower.toUpperCase();
|
188
186
|
}
|
package/dist/tag/dynamic-tag.js
CHANGED
@@ -18,8 +18,15 @@ function _default(path) {
|
|
18
18
|
tagProperties.push(
|
19
19
|
_compiler.types.objectProperty(
|
20
20
|
_compiler.types.identifier("pa"),
|
21
|
-
_compiler.types.
|
22
|
-
node.preserveAttrs.map((name) =>
|
21
|
+
_compiler.types.objectExpression(
|
22
|
+
node.preserveAttrs.map((name) =>
|
23
|
+
_compiler.types.objectProperty(
|
24
|
+
_compiler.types.isValidIdentifier(name) ?
|
25
|
+
_compiler.types.identifier(name) :
|
26
|
+
_compiler.types.stringLiteral(name),
|
27
|
+
_compiler.types.numericLiteral(1)
|
28
|
+
)
|
29
|
+
)
|
23
30
|
)
|
24
31
|
)
|
25
32
|
);
|
package/dist/tag/index.js
CHANGED
@@ -13,11 +13,11 @@ var _keyManager = require("../util/key-manager");
|
|
13
13
|
var _optimizeVdomCreate = require("../util/optimize-vdom-create");
|
14
14
|
var _pluginHooks = require("../util/plugin-hooks");
|
15
15
|
var _attribute = _interopRequireDefault(require("./attribute"));
|
16
|
-
var _attributeTag =
|
16
|
+
var _attributeTag = _interopRequireWildcard(require("./attribute-tag"));
|
17
17
|
var _customTag = _interopRequireDefault(require("./custom-tag"));
|
18
18
|
var _dynamicTag = _interopRequireDefault(require("./dynamic-tag"));
|
19
19
|
var _macroTag = _interopRequireDefault(require("./macro-tag"));
|
20
|
-
var _nativeTag = _interopRequireDefault(require("./native-tag"));var _default = exports.default =
|
20
|
+
var _nativeTag = _interopRequireDefault(require("./native-tag"));function _getRequireWildcardCache(e) {if ("function" != typeof WeakMap) return null;var r = new WeakMap(),t = new WeakMap();return (_getRequireWildcardCache = function (e) {return e ? t : r;})(e);}function _interopRequireWildcard(e, r) {if (!r && e && e.__esModule) return e;if (null === e || "object" != typeof e && "function" != typeof e) return { default: e };var t = _getRequireWildcardCache(r);if (t && t.has(e)) return t.get(e);var n = { __proto__: null },a = Object.defineProperty && Object.getOwnPropertyDescriptor;for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) {var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];}return n.default = e, t && t.set(e, n), n;}var _default = exports.default =
|
21
21
|
|
22
22
|
{
|
23
23
|
enter(path) {
|
@@ -54,6 +54,10 @@ var _nativeTag = _interopRequireDefault(require("./native-tag"));var _default =
|
|
54
54
|
}
|
55
55
|
|
56
56
|
if (!(0, _babelUtils.isAttributeTag)(path)) {
|
57
|
+
if ((0, _babelUtils.isDynamicTag)(path) || !((0, _babelUtils.isMacroTag)(path) || (0, _babelUtils.isNativeTag)(path))) {
|
58
|
+
(0, _attributeTag.analyzeAttributeTags)(path);
|
59
|
+
}
|
60
|
+
|
57
61
|
(0, _keyManager.getKeyManager)(path).resolveKey(path);
|
58
62
|
}
|
59
63
|
|
@@ -75,8 +75,15 @@ function _default(path, isNullable) {
|
|
75
75
|
tagProperties.push(
|
76
76
|
_compiler.types.objectProperty(
|
77
77
|
_compiler.types.identifier("pa"),
|
78
|
-
_compiler.types.
|
79
|
-
node.preserveAttrs.map((name) =>
|
78
|
+
_compiler.types.objectExpression(
|
79
|
+
node.preserveAttrs.map((name) =>
|
80
|
+
_compiler.types.objectProperty(
|
81
|
+
_compiler.types.isValidIdentifier(name) ?
|
82
|
+
_compiler.types.identifier(name) :
|
83
|
+
_compiler.types.stringLiteral(name),
|
84
|
+
_compiler.types.numericLiteral(1)
|
85
|
+
)
|
86
|
+
)
|
80
87
|
)
|
81
88
|
)
|
82
89
|
);
|
@@ -116,8 +116,15 @@ function tagArguments(path) {
|
|
116
116
|
tagProperties.push(
|
117
117
|
_compiler.types.objectProperty(
|
118
118
|
_compiler.types.identifier("pa"),
|
119
|
-
_compiler.types.
|
120
|
-
node.preserveAttrs.map((name) =>
|
119
|
+
_compiler.types.objectExpression(
|
120
|
+
node.preserveAttrs.map((name) =>
|
121
|
+
_compiler.types.objectProperty(
|
122
|
+
_compiler.types.isValidIdentifier(name) ?
|
123
|
+
_compiler.types.identifier(name) :
|
124
|
+
_compiler.types.stringLiteral(name),
|
125
|
+
_compiler.types.numericLiteral(1)
|
126
|
+
)
|
127
|
+
)
|
121
128
|
)
|
122
129
|
)
|
123
130
|
);
|
package/dist/tag/util.js
CHANGED
@@ -3,12 +3,12 @@ var _compiler = require("@marko/compiler");
|
|
3
3
|
var _classValue = _interopRequireDefault(require("marko/src/runtime/helpers/class-value"));
|
4
4
|
var _styleValue = _interopRequireDefault(require("marko/src/runtime/helpers/style-value"));
|
5
5
|
|
6
|
-
function getAttrs(path, preserveNames
|
6
|
+
function getAttrs(path, preserveNames) {
|
7
7
|
const { node } = path;
|
8
8
|
const {
|
9
|
+
extra,
|
9
10
|
attributes,
|
10
|
-
body: { body, params }
|
11
|
-
hasDynamicAttrTags
|
11
|
+
body: { body, params }
|
12
12
|
} = node;
|
13
13
|
const attrsLen = attributes.length;
|
14
14
|
const childLen = body.length;
|
@@ -16,6 +16,7 @@ function getAttrs(path, preserveNames, skipRenderBody) {
|
|
16
16
|
const targetObjects = {};
|
17
17
|
const tagDef = (0, _babelUtils.getTagDef)(path);
|
18
18
|
const foundProperties = {};
|
19
|
+
const hasAttributeTags = extra?.hasAttributeTags;
|
19
20
|
|
20
21
|
for (let i = 0; i < attrsLen; i++) {
|
21
22
|
const { name, value } = attributes[i];
|
@@ -69,34 +70,16 @@ function getAttrs(path, preserveNames, skipRenderBody) {
|
|
69
70
|
}
|
70
71
|
}
|
71
72
|
|
72
|
-
if (
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
);
|
80
|
-
path.
|
81
|
-
insertBefore(body.slice(0, endDynamicAttrTagsIndex)).
|
82
|
-
map((child) => child.skip());
|
83
|
-
}
|
84
|
-
|
85
|
-
if (!hasDynamicAttrTags || endDynamicAttrTagsIndex !== childLen - 1) {
|
86
|
-
properties.push(
|
87
|
-
_compiler.types.objectProperty(
|
88
|
-
_compiler.types.stringLiteral("renderBody"),
|
89
|
-
_compiler.types.arrowFunctionExpression(
|
90
|
-
[_compiler.types.identifier("out"), ...params],
|
91
|
-
_compiler.types.blockStatement(
|
92
|
-
hasDynamicAttrTags ?
|
93
|
-
body.slice(endDynamicAttrTagsIndex + 1) :
|
94
|
-
body
|
95
|
-
)
|
96
|
-
)
|
73
|
+
if (childLen && !hasAttributeTags) {
|
74
|
+
properties.push(
|
75
|
+
_compiler.types.objectProperty(
|
76
|
+
_compiler.types.stringLiteral("renderBody"),
|
77
|
+
_compiler.types.arrowFunctionExpression(
|
78
|
+
[_compiler.types.identifier("out"), ...params],
|
79
|
+
_compiler.types.blockStatement(body)
|
97
80
|
)
|
98
|
-
)
|
99
|
-
|
81
|
+
)
|
82
|
+
);
|
100
83
|
}
|
101
84
|
|
102
85
|
// Default parameters
|
@@ -121,15 +104,55 @@ function getAttrs(path, preserveNames, skipRenderBody) {
|
|
121
104
|
}
|
122
105
|
});
|
123
106
|
|
124
|
-
|
125
|
-
|
126
|
-
|
107
|
+
let attrsObject =
|
108
|
+
properties.length === 0 ?
|
109
|
+
_compiler.types.nullLiteral() :
|
110
|
+
!hasAttributeTags &&
|
111
|
+
properties.length === 1 &&
|
112
|
+
_compiler.types.isSpreadElement(properties[0]) ?
|
113
|
+
properties[0].argument :
|
114
|
+
_compiler.types.objectExpression(properties);
|
115
|
+
|
116
|
+
if (hasAttributeTags) {
|
117
|
+
const endAttributeTagsIndex = findLastIndex(
|
118
|
+
body,
|
119
|
+
(node) =>
|
120
|
+
_compiler.types.isExpressionStatement(node) &&
|
121
|
+
_compiler.types.isStringLiteral(node.expression) &&
|
122
|
+
node.expression.value === "END_ATTRIBUTE_TAGS"
|
123
|
+
);
|
124
|
+
|
125
|
+
let attrTagBody = body;
|
126
|
+
|
127
|
+
if (endAttributeTagsIndex !== -1) {
|
128
|
+
attrTagBody = body.slice(0, endAttributeTagsIndex);
|
129
|
+
attrTagBody.push(
|
130
|
+
_compiler.types.returnStatement(
|
131
|
+
_compiler.types.arrowFunctionExpression(
|
132
|
+
[_compiler.types.identifier("out"), ...params],
|
133
|
+
_compiler.types.blockStatement(body.slice(endAttributeTagsIndex + 1))
|
134
|
+
)
|
135
|
+
)
|
136
|
+
);
|
137
|
+
}
|
127
138
|
|
128
|
-
|
129
|
-
|
139
|
+
const attrTagFn = _compiler.types.arrowFunctionExpression(
|
140
|
+
[],
|
141
|
+
_compiler.types.blockStatement(attrTagBody)
|
142
|
+
);
|
143
|
+
|
144
|
+
attrsObject = _compiler.types.callExpression(
|
145
|
+
(0, _babelUtils.importNamed)(
|
146
|
+
path.hub.file,
|
147
|
+
"marko/src/runtime/helpers/attr-tag.js",
|
148
|
+
"i",
|
149
|
+
"marko_render_input"
|
150
|
+
),
|
151
|
+
properties.length === 0 ? [attrTagFn] : [attrTagFn, attrsObject]
|
152
|
+
);
|
130
153
|
}
|
131
154
|
|
132
|
-
return
|
155
|
+
return attrsObject;
|
133
156
|
}
|
134
157
|
|
135
158
|
function buildEventHandlerArray(path) {
|
@@ -207,6 +230,8 @@ function findLastIndex(arr, check) {
|
|
207
230
|
return i;
|
208
231
|
}
|
209
232
|
}
|
233
|
+
|
234
|
+
return -1;
|
210
235
|
}
|
211
236
|
|
212
237
|
function mergeSpread(properties, value) {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@marko/translator-default",
|
3
|
-
"version": "5.31.
|
3
|
+
"version": "5.31.16",
|
4
4
|
"description": "Translates Marko templates to the default Marko runtime.",
|
5
5
|
"keywords": [
|
6
6
|
"babel",
|
@@ -34,8 +34,8 @@
|
|
34
34
|
"self-closing-tags": "^1.0.1"
|
35
35
|
},
|
36
36
|
"devDependencies": {
|
37
|
-
"@marko/compiler": "^5.34.
|
38
|
-
"marko": "^5.32.
|
37
|
+
"@marko/compiler": "^5.34.7",
|
38
|
+
"marko": "^5.32.11"
|
39
39
|
},
|
40
40
|
"peerDependencies": {
|
41
41
|
"@marko/compiler": "^5.16.1",
|