@marko/translator-default 5.31.0 → 5.31.2

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.
Files changed (44) hide show
  1. package/dist/cdata/index[html].js +5 -5
  2. package/dist/cdata/index[vdom].js +2 -2
  3. package/dist/class.js +21 -21
  4. package/dist/comment/index[html].js +2 -2
  5. package/dist/declaration/index[html].js +2 -2
  6. package/dist/document-type/index[html].js +2 -2
  7. package/dist/index.js +165 -165
  8. package/dist/placeholder/index[html].js +17 -17
  9. package/dist/placeholder/index[vdom].js +5 -5
  10. package/dist/tag/attribute/directives/class.js +12 -12
  11. package/dist/tag/attribute/directives/no-update.js +8 -8
  12. package/dist/tag/attribute/directives/style.js +12 -12
  13. package/dist/tag/attribute/index.js +15 -15
  14. package/dist/tag/attribute/modifiers/scoped.js +11 -11
  15. package/dist/tag/attribute-tag.js +67 -67
  16. package/dist/tag/custom-tag.js +37 -37
  17. package/dist/tag/dynamic-tag.js +29 -29
  18. package/dist/tag/index.js +9 -9
  19. package/dist/tag/native-tag[html]/attributes.js +41 -41
  20. package/dist/tag/native-tag[html]/index.js +67 -67
  21. package/dist/tag/native-tag[vdom]/attributes.js +34 -34
  22. package/dist/tag/native-tag[vdom]/index.js +59 -59
  23. package/dist/tag/util.js +42 -42
  24. package/dist/taglib/core/conditional/translate-else-if.js +2 -2
  25. package/dist/taglib/core/conditional/translate-else.js +2 -2
  26. package/dist/taglib/core/conditional/util.js +5 -5
  27. package/dist/taglib/core/macro/translate.js +9 -9
  28. package/dist/taglib/core/parse-class.js +2 -2
  29. package/dist/taglib/core/transform-style.js +6 -6
  30. package/dist/taglib/core/translate-await.js +11 -11
  31. package/dist/taglib/core/translate-body.js +5 -5
  32. package/dist/taglib/core/translate-for.js +65 -65
  33. package/dist/taglib/core/translate-include-content.js +9 -9
  34. package/dist/taglib/core/translate-while.js +10 -10
  35. package/dist/taglib/migrate/all-templates.js +8 -8
  36. package/dist/text/index[html].js +2 -2
  37. package/dist/text/index[vdom].js +9 -9
  38. package/dist/util/add-dependencies.js +38 -38
  39. package/dist/util/get-component-files.js +2 -2
  40. package/dist/util/html-out-write.js +5 -5
  41. package/dist/util/key-manager.js +27 -27
  42. package/dist/util/optimize-vdom-create.js +31 -31
  43. package/dist/util/vdom-out-write.js +5 -5
  44. package/package.json +3 -3
@@ -8,13 +8,13 @@ function _default(path, attrs) {
8
8
  if (len === 0) return _compiler.types.stringLiteral("");
9
9
  if (len === 1 && attrs[0].node.type === "MarkoSpreadAttribute") {
10
10
  return _compiler.types.callExpression(
11
- (0, _babelUtils.importDefault)(
12
- path.hub.file,
13
- "marko/src/runtime/html/helpers/attrs.js",
14
- "marko_attrs"),
15
-
16
- [attrs[0].node.value]);
17
-
11
+ (0, _babelUtils.importDefault)(
12
+ path.hub.file,
13
+ "marko/src/runtime/html/helpers/attrs.js",
14
+ "marko_attrs"
15
+ ),
16
+ [attrs[0].node.value]
17
+ );
18
18
  }
19
19
 
20
20
  if (attrs.some((attr) => attr.node.type === "MarkoSpreadAttribute")) {
@@ -30,11 +30,11 @@ function _default(path, attrs) {
30
30
  if (name) {
31
31
  const computed = (0, _util.evaluateAttr)(attr);
32
32
  const prop = _compiler.types.objectProperty(
33
- _compiler.types.stringLiteral(name),
34
- (computed == null ? void 0 : computed.value) !== undefined ?
35
- _compiler.types.stringLiteral(computed.value) :
36
- value);
37
-
33
+ _compiler.types.stringLiteral(name),
34
+ (computed == null ? void 0 : computed.value) !== undefined ?
35
+ _compiler.types.stringLiteral(computed.value) :
36
+ value
37
+ );
38
38
  if (props) {
39
39
  props.push(prop);
40
40
  } else {
@@ -47,13 +47,13 @@ function _default(path, attrs) {
47
47
  }
48
48
 
49
49
  return _compiler.types.callExpression(
50
- (0, _babelUtils.importDefault)(
51
- path.hub.file,
52
- "marko/src/runtime/html/helpers/merge-attrs.js",
53
- "marko_merge_attrs"),
54
-
55
- attrsObjects);
56
-
50
+ (0, _babelUtils.importDefault)(
51
+ path.hub.file,
52
+ "marko/src/runtime/html/helpers/merge-attrs.js",
53
+ "marko_merge_attrs"
54
+ ),
55
+ attrsObjects
56
+ );
57
57
  }
58
58
 
59
59
  const file = path.hub.file;
@@ -69,19 +69,19 @@ function _default(path, attrs) {
69
69
  if (attrValues.has(name)) continue;
70
70
  const computed = (0, _util.evaluateAttr)(attr);
71
71
  attrValues.set(
72
- name,
73
- computed ?
74
- {
75
- confident: true,
76
- computed: computed.value,
77
- value
78
- } :
79
- {
80
- confident: false,
81
- computed: undefined,
82
- value
83
- });
84
-
72
+ name,
73
+ computed ?
74
+ {
75
+ confident: true,
76
+ computed: computed.value,
77
+ value
78
+ } :
79
+ {
80
+ confident: false,
81
+ computed: undefined,
82
+ value
83
+ }
84
+ );
85
85
  }
86
86
 
87
87
  for (const [name, { confident, computed, value }] of [
@@ -97,15 +97,15 @@ function _default(path, attrs) {
97
97
  quasis.push(curString);
98
98
  curString = "";
99
99
  expressions.push(
100
- _compiler.types.callExpression(
101
- (0, _babelUtils.importDefault)(
102
- file,
103
- "marko/src/runtime/html/helpers/attr.js",
104
- "marko_attr"),
105
-
106
- [_compiler.types.stringLiteral(name), value]));
107
-
108
-
100
+ _compiler.types.callExpression(
101
+ (0, _babelUtils.importDefault)(
102
+ file,
103
+ "marko/src/runtime/html/helpers/attr.js",
104
+ "marko_attr"
105
+ ),
106
+ [_compiler.types.stringLiteral(name), value]
107
+ )
108
+ );
109
109
  }
110
110
  }
111
111
 
@@ -41,31 +41,31 @@ function _default(path, isNullable) {
41
41
 
42
42
  if (handlers) {
43
43
  Object.entries(handlers).forEach(
44
- ([eventName, { arguments: args, once }]) => {
45
- const delegateArgs = [_compiler.types.stringLiteral(eventName), args[0]];
44
+ ([eventName, { arguments: args, once }]) => {
45
+ const delegateArgs = [_compiler.types.stringLiteral(eventName), args[0]];
46
46
 
47
- // TODO: look into only sending this if once is true.
48
- delegateArgs.push(_compiler.types.booleanLiteral(once));
47
+ // TODO: look into only sending this if once is true.
48
+ delegateArgs.push(_compiler.types.booleanLiteral(once));
49
49
 
50
- if (args.length > 1) {
51
- delegateArgs.push(_compiler.types.arrayExpression(args.slice(1)));
52
- }
53
-
54
- // TODO: why do we output eventName twice.
55
- tagProperties.push(
56
- _compiler.types.objectProperty(
57
- _compiler.types.stringLiteral(`on${eventName}`),
58
- _compiler.types.callExpression(
59
- _compiler.types.memberExpression(
60
- file._componentDefIdentifier,
61
- _compiler.types.identifier("d")),
62
-
63
- delegateArgs)));
64
-
65
-
66
-
67
- });
50
+ if (args.length > 1) {
51
+ delegateArgs.push(_compiler.types.arrayExpression(args.slice(1)));
52
+ }
68
53
 
54
+ // TODO: why do we output eventName twice.
55
+ tagProperties.push(
56
+ _compiler.types.objectProperty(
57
+ _compiler.types.stringLiteral(`on${eventName}`),
58
+ _compiler.types.callExpression(
59
+ _compiler.types.memberExpression(
60
+ file._componentDefIdentifier,
61
+ _compiler.types.identifier("d")
62
+ ),
63
+ delegateArgs
64
+ )
65
+ )
66
+ );
67
+ }
68
+ );
69
69
  }
70
70
 
71
71
  const isHTML = file.markoOpts.output === "html";
@@ -73,13 +73,13 @@ function _default(path, isNullable) {
73
73
 
74
74
  if (node.preserveAttrs) {
75
75
  tagProperties.push(
76
- _compiler.types.objectProperty(
77
- _compiler.types.identifier("pa"),
78
- _compiler.types.arrayExpression(
79
- node.preserveAttrs.map((name) => _compiler.types.stringLiteral(name)))));
80
-
81
-
82
-
76
+ _compiler.types.objectProperty(
77
+ _compiler.types.identifier("pa"),
78
+ _compiler.types.arrayExpression(
79
+ node.preserveAttrs.map((name) => _compiler.types.stringLiteral(name))
80
+ )
81
+ )
82
+ );
83
83
  }
84
84
 
85
85
  if (isHTML) {
@@ -105,13 +105,13 @@ function _default(path, isNullable) {
105
105
 
106
106
  if (dataMarkoArgs.length > 2) {
107
107
  dataMarko = _compiler.types.callExpression(
108
- (0, _babelUtils.importDefault)(
109
- file,
110
- "marko/src/runtime/html/helpers/data-marko.js",
111
- "marko_props"),
112
-
113
- dataMarkoArgs);
114
-
108
+ (0, _babelUtils.importDefault)(
109
+ file,
110
+ "marko/src/runtime/html/helpers/data-marko.js",
111
+ "marko_props"
112
+ ),
113
+ dataMarkoArgs
114
+ );
115
115
  }
116
116
  }
117
117
  }
@@ -139,27 +139,27 @@ function _default(path, isNullable) {
139
139
  let writeStartNode = (0, _babelUtils.normalizeTemplateString)`<${name}${dataMarko}${translatedAttrs}${openTagEnding}`;
140
140
 
141
141
  writeStartNode = (0, _withPreviousLocation.default)(
142
- isEmpty && !isSelfClosing ?
143
- (0, _htmlOutWrite.default)`${writeStartNode}</${name}>` :
144
- (0, _htmlOutWrite.default)`${writeStartNode}`,
145
- name);
146
-
142
+ isEmpty && !isSelfClosing ?
143
+ (0, _htmlOutWrite.default)`${writeStartNode}</${name}>` :
144
+ (0, _htmlOutWrite.default)`${writeStartNode}`,
145
+ name
146
+ );
147
147
 
148
148
  if (isNullable) {
149
149
  writeStartNode = _compiler.types.ifStatement(
150
- name,
151
- writeStartNode,
152
- _compiler.types.expressionStatement(
153
- _compiler.types.callExpression(
154
- _compiler.types.memberExpression(_compiler.types.identifier("out"), _compiler.types.identifier("bf")),
155
- [
156
- (0, _babelUtils.normalizeTemplateString)`f_${key}`,
157
- file._componentInstanceIdentifier,
158
- _compiler.types.numericLiteral(1)])));
159
-
160
-
161
-
162
-
150
+ name,
151
+ writeStartNode,
152
+ _compiler.types.expressionStatement(
153
+ _compiler.types.callExpression(
154
+ _compiler.types.memberExpression(_compiler.types.identifier("out"), _compiler.types.identifier("bf")),
155
+ [
156
+ (0, _babelUtils.normalizeTemplateString)`f_${key}`,
157
+ file._componentInstanceIdentifier,
158
+ _compiler.types.numericLiteral(1)]
159
+
160
+ )
161
+ )
162
+ );
163
163
  }
164
164
 
165
165
  if (isEmpty) {
@@ -181,22 +181,22 @@ function _default(path, isNullable) {
181
181
 
182
182
  if (isNullable) {
183
183
  writeEndNode = _compiler.types.ifStatement(
184
- name,
185
- writeEndNode,
186
- _compiler.types.expressionStatement(
187
- _compiler.types.callExpression(
188
- _compiler.types.memberExpression(_compiler.types.identifier("out"), _compiler.types.identifier("ef")),
189
- [])));
190
-
191
-
192
-
184
+ name,
185
+ writeEndNode,
186
+ _compiler.types.expressionStatement(
187
+ _compiler.types.callExpression(
188
+ _compiler.types.memberExpression(_compiler.types.identifier("out"), _compiler.types.identifier("ef")),
189
+ []
190
+ )
191
+ )
192
+ );
193
193
  }
194
194
 
195
195
  path.replaceWithMultiple(
196
- [writeStartNode].
197
- concat(needsBlock ? _compiler.types.blockStatement(body) : body).
198
- concat(writeEndNode));
199
-
196
+ [writeStartNode].
197
+ concat(needsBlock ? _compiler.types.blockStatement(body) : body).
198
+ concat(writeEndNode)
199
+ );
200
200
  }
201
201
 
202
202
  function isPreserved(path) {
@@ -7,13 +7,13 @@ function _default(path, attrs) {
7
7
  if (len === 0) return _compiler.types.nullLiteral();
8
8
  if (len === 1 && attrs[0].node.type === "MarkoSpreadAttribute") {
9
9
  return _compiler.types.callExpression(
10
- (0, _babelUtils.importDefault)(
11
- path.hub.file,
12
- "marko/src/runtime/vdom/helpers/attrs.js",
13
- "marko_attrs"),
14
-
15
- [attrs[0].node.value]);
16
-
10
+ (0, _babelUtils.importDefault)(
11
+ path.hub.file,
12
+ "marko/src/runtime/vdom/helpers/attrs.js",
13
+ "marko_attrs"
14
+ ),
15
+ [attrs[0].node.value]
16
+ );
17
17
  }
18
18
 
19
19
  if (attrs.some((attr) => attr.node.type === "MarkoSpreadAttribute")) {
@@ -29,11 +29,11 @@ function _default(path, attrs) {
29
29
  if (name) {
30
30
  const computed = (0, _util.evaluateAttr)(attr);
31
31
  const prop = _compiler.types.objectProperty(
32
- _compiler.types.stringLiteral(name),
33
- (computed == null ? void 0 : computed.value) !== undefined ?
34
- _compiler.types.stringLiteral(computed.value) :
35
- value);
36
-
32
+ _compiler.types.stringLiteral(name),
33
+ (computed == null ? void 0 : computed.value) !== undefined ?
34
+ _compiler.types.stringLiteral(computed.value) :
35
+ value
36
+ );
37
37
  if (props) {
38
38
  props.push(prop);
39
39
  } else {
@@ -46,13 +46,13 @@ function _default(path, attrs) {
46
46
  }
47
47
 
48
48
  return _compiler.types.callExpression(
49
- (0, _babelUtils.importDefault)(
50
- path.hub.file,
51
- "marko/src/runtime/vdom/helpers/merge-attrs.js",
52
- "marko_merge_attrs"),
53
-
54
- attrsObjects);
55
-
49
+ (0, _babelUtils.importDefault)(
50
+ path.hub.file,
51
+ "marko/src/runtime/vdom/helpers/merge-attrs.js",
52
+ "marko_merge_attrs"
53
+ ),
54
+ attrsObjects
55
+ );
56
56
  }
57
57
 
58
58
  const attrValues = new Map();
@@ -65,19 +65,19 @@ function _default(path, attrs) {
65
65
  if (attrValues.has(name)) continue;
66
66
  const computed = (0, _util.evaluateAttr)(attr);
67
67
  attrValues.set(
68
- name,
69
- computed ?
70
- {
71
- confident: true,
72
- computed: computed.value,
73
- value
74
- } :
75
- {
76
- confident: false,
77
- computed: undefined,
78
- value
79
- });
80
-
68
+ name,
69
+ computed ?
70
+ {
71
+ confident: true,
72
+ computed: computed.value,
73
+ value
74
+ } :
75
+ {
76
+ confident: false,
77
+ computed: undefined,
78
+ value
79
+ }
80
+ );
81
81
  }
82
82
 
83
83
  for (const [name, { confident, computed, value }] of [
@@ -89,8 +89,8 @@ function _default(path, attrs) {
89
89
  }
90
90
 
91
91
  props.push(
92
- _compiler.types.objectProperty(_compiler.types.stringLiteral(name), _compiler.types.stringLiteral(computed)));
93
-
92
+ _compiler.types.objectProperty(_compiler.types.stringLiteral(name), _compiler.types.stringLiteral(computed))
93
+ );
94
94
  } else {
95
95
  props.push(_compiler.types.objectProperty(_compiler.types.stringLiteral(name), value));
96
96
  }
@@ -47,42 +47,42 @@ function tagArguments(path, isStatic) {
47
47
 
48
48
  if (node.preserveAttrs) {
49
49
  tagProperties.push(
50
- _compiler.types.objectProperty(
51
- _compiler.types.identifier("pa"),
52
- _compiler.types.arrayExpression(
53
- node.preserveAttrs.map((name) => _compiler.types.stringLiteral(name)))));
54
-
55
-
56
-
50
+ _compiler.types.objectProperty(
51
+ _compiler.types.identifier("pa"),
52
+ _compiler.types.arrayExpression(
53
+ node.preserveAttrs.map((name) => _compiler.types.stringLiteral(name))
54
+ )
55
+ )
56
+ );
57
57
  }
58
58
 
59
59
  if (handlers) {
60
60
  Object.entries(handlers).forEach(
61
- ([eventName, { arguments: args, once }]) => {
62
- const delegateArgs = [_compiler.types.stringLiteral(eventName), args[0]];
63
-
64
- // TODO: look into only sending this if once is true.
65
- delegateArgs.push(_compiler.types.booleanLiteral(once));
66
-
67
- if (args.length > 1) {
68
- delegateArgs.push(_compiler.types.arrayExpression(args.slice(1)));
61
+ ([eventName, { arguments: args, once }]) => {
62
+ const delegateArgs = [_compiler.types.stringLiteral(eventName), args[0]];
63
+
64
+ // TODO: look into only sending this if once is true.
65
+ delegateArgs.push(_compiler.types.booleanLiteral(once));
66
+
67
+ if (args.length > 1) {
68
+ delegateArgs.push(_compiler.types.arrayExpression(args.slice(1)));
69
+ }
70
+
71
+ // TODO: why do we output eventName twice.
72
+ tagProperties.push(
73
+ _compiler.types.objectProperty(
74
+ _compiler.types.stringLiteral(`on${eventName}`),
75
+ _compiler.types.callExpression(
76
+ _compiler.types.memberExpression(
77
+ file._componentDefIdentifier,
78
+ _compiler.types.identifier("d")
79
+ ),
80
+ delegateArgs
81
+ )
82
+ )
83
+ );
69
84
  }
70
-
71
- // TODO: why do we output eventName twice.
72
- tagProperties.push(
73
- _compiler.types.objectProperty(
74
- _compiler.types.stringLiteral(`on${eventName}`),
75
- _compiler.types.callExpression(
76
- _compiler.types.memberExpression(
77
- file._componentDefIdentifier,
78
- _compiler.types.identifier("d")),
79
-
80
- delegateArgs)));
81
-
82
-
83
-
84
- });
85
-
85
+ );
86
86
  }
87
87
 
88
88
  if (
@@ -134,24 +134,24 @@ function _default(path, isNullable) {
134
134
  const isEmpty = !body.length;
135
135
  const writeArgs = tagArguments(path, false);
136
136
  let writeStartNode = (0, _withPreviousLocation.default)(
137
- (0, _vdomOutWrite.default)(isEmpty ? "e" : "be", ...writeArgs),
138
- node.name);
139
-
137
+ (0, _vdomOutWrite.default)(isEmpty ? "e" : "be", ...writeArgs),
138
+ node.name
139
+ );
140
140
 
141
141
  if (isNullable) {
142
142
  writeStartNode = _compiler.types.ifStatement(
143
- name,
144
- writeStartNode,
145
- _compiler.types.expressionStatement(
146
- _compiler.types.callExpression(
147
- _compiler.types.memberExpression(_compiler.types.identifier("out"), _compiler.types.identifier("bf")),
148
- [
149
- (0, _babelUtils.normalizeTemplateString)`f_${key}`,
150
- path.hub.file._componentInstanceIdentifier])));
151
-
152
-
153
-
154
-
143
+ name,
144
+ writeStartNode,
145
+ _compiler.types.expressionStatement(
146
+ _compiler.types.callExpression(
147
+ _compiler.types.memberExpression(_compiler.types.identifier("out"), _compiler.types.identifier("bf")),
148
+ [
149
+ (0, _babelUtils.normalizeTemplateString)`f_${key}`,
150
+ path.hub.file._componentInstanceIdentifier]
151
+
152
+ )
153
+ )
154
+ );
155
155
  }
156
156
 
157
157
  if (isEmpty) {
@@ -162,15 +162,15 @@ function _default(path, isNullable) {
162
162
  let writeEndNode = (0, _vdomOutWrite.default)("ee");
163
163
  if (isNullable) {
164
164
  writeEndNode = _compiler.types.ifStatement(
165
- name,
166
- writeEndNode,
167
- _compiler.types.expressionStatement(
168
- _compiler.types.callExpression(
169
- _compiler.types.memberExpression(_compiler.types.identifier("out"), _compiler.types.identifier("ef")),
170
- [])));
171
-
172
-
173
-
165
+ name,
166
+ writeEndNode,
167
+ _compiler.types.expressionStatement(
168
+ _compiler.types.callExpression(
169
+ _compiler.types.memberExpression(_compiler.types.identifier("out"), _compiler.types.identifier("ef")),
170
+ []
171
+ )
172
+ )
173
+ );
174
174
  }
175
175
 
176
176
  let needsBlock;
@@ -184,10 +184,10 @@ function _default(path, isNullable) {
184
184
  }
185
185
 
186
186
  path.replaceWithMultiple(
187
- [writeStartNode].
188
- concat(needsBlock ? _compiler.types.blockStatement(body) : body).
189
- concat(writeEndNode));
190
-
187
+ [writeStartNode].
188
+ concat(needsBlock ? _compiler.types.blockStatement(body) : body).
189
+ concat(writeEndNode)
190
+ );
191
191
  }
192
192
 
193
193
  function isPropertyName({ key }, names) {