ember-scoped-css 3.4.0 → 3.5.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/dist/cjs/{all-DurjGbDW.cjs → all-G01Li-a4.cjs} +192 -13
- package/dist/cjs/all.cjs +1 -1
- package/dist/cjs/babel.cjs +1 -1
- package/dist/cjs/rollup.cjs +1 -1
- package/dist/cjs/vite.cjs +1 -1
- package/package.json +1 -1
- package/src/lib/rewriteHbs.classes.concat.test.ts +108 -0
- package/src/lib/rewriteHbs.js +230 -19
package/dist/cjs/all.cjs
CHANGED
package/dist/cjs/babel.cjs
CHANGED
package/dist/cjs/rollup.cjs
CHANGED
package/dist/cjs/vite.cjs
CHANGED
package/package.json
CHANGED
|
@@ -154,3 +154,111 @@ describe('concat in a class attribute', () => {
|
|
|
154
154
|
).to.equal('<div class={{if x (concat "a_pfx" " " "b_pfx") "c"}}></div>');
|
|
155
155
|
});
|
|
156
156
|
});
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* A `concat` nested inside an `if`/`unless` branch survives as a call (the
|
|
160
|
+
* branch has to stay one value), so a param fused onto a nested `if`/`unless`
|
|
161
|
+
* -- "a" and (if x "-on" "-off") share no boundary -- is never a whole class
|
|
162
|
+
* name on its own; the boundary-aware rename above has nothing to postfix.
|
|
163
|
+
* But every class the branch could actually produce is still known ahead of
|
|
164
|
+
* time, so enumerating them lets the fused run collapse into an `if`/`unless`
|
|
165
|
+
* over the renamed classes instead, with nothing left for `concat` to join.
|
|
166
|
+
*/
|
|
167
|
+
describe('a concat nested in an if/unless branch, fused onto a nested condition', () => {
|
|
168
|
+
const classesWithVariants = new Set(['a', 'b', 'a-on', 'a-off']);
|
|
169
|
+
const rewriteWithVariants = (hbs) =>
|
|
170
|
+
rewriteHbs(hbs, classesWithVariants, new Set(), postfix);
|
|
171
|
+
|
|
172
|
+
it('distributes over a nested if, replacing the concat with an if over the renamed classes', () => {
|
|
173
|
+
expect(
|
|
174
|
+
rewriteWithVariants(
|
|
175
|
+
'<div class={{if outer (concat "a" (if x "-on" "-off")) "global-thing"}}></div>',
|
|
176
|
+
),
|
|
177
|
+
).to.equal(
|
|
178
|
+
'<div class={{if outer (if x "a-on_pfx" "a-off_pfx") "global-thing"}}></div>',
|
|
179
|
+
);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it('distributes over a nested unless, inverting the branches it reaches through', () => {
|
|
183
|
+
// unless resolves to its second param when falsy and its third when
|
|
184
|
+
// truthy -- the opposite of if -- so the if built in its place has to
|
|
185
|
+
// reach each renamed class through the opposite branch.
|
|
186
|
+
expect(
|
|
187
|
+
rewriteWithVariants(
|
|
188
|
+
'<div class={{if outer (concat "a" (unless x "-on" "-off")) "global-thing"}}></div>',
|
|
189
|
+
),
|
|
190
|
+
).to.equal(
|
|
191
|
+
'<div class={{if outer (if x "a-off_pfx" "a-on_pfx") "global-thing"}}></div>',
|
|
192
|
+
);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it('leaves the concat as a call when a fused param is a genuine runtime value', () => {
|
|
196
|
+
// this.suffix has no statically-known value to enumerate, so the classes
|
|
197
|
+
// the concat could produce aren't knowable ahead of time.
|
|
198
|
+
expect(
|
|
199
|
+
rewriteWithVariants(
|
|
200
|
+
'<div class={{if outer (concat "a" this.suffix) "global-thing"}}></div>',
|
|
201
|
+
),
|
|
202
|
+
).to.equal(
|
|
203
|
+
'<div class={{if outer (concat "a" this.suffix) "global-thing"}}></div>',
|
|
204
|
+
);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('leaves the concat as a call when a fused param is an opaque helper call', () => {
|
|
208
|
+
expect(
|
|
209
|
+
rewriteWithVariants(
|
|
210
|
+
'<div class={{if outer (concat "a" (someHelper "z")) "global-thing"}}></div>',
|
|
211
|
+
),
|
|
212
|
+
).to.equal(
|
|
213
|
+
'<div class={{if outer (concat "a" (someHelper "z")) "global-thing"}}></div>',
|
|
214
|
+
);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it('distributes over two independent conditions', () => {
|
|
218
|
+
const classesWithBothVariants = new Set(['a-on', 'a-off', 'b-on', 'b-off']);
|
|
219
|
+
|
|
220
|
+
expect(
|
|
221
|
+
rewriteHbs(
|
|
222
|
+
'<div class={{if outer (concat (if p "a" "b") (if q "-on" "-off")) "global-thing"}}></div>',
|
|
223
|
+
classesWithBothVariants,
|
|
224
|
+
new Set(),
|
|
225
|
+
postfix,
|
|
226
|
+
),
|
|
227
|
+
).to.equal(
|
|
228
|
+
'<div class={{if outer (if p (if q "a-on_pfx" "a-off_pfx") (if q "b-on_pfx" "b-off_pfx")) "global-thing"}}></div>',
|
|
229
|
+
);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it('leaves the concat as a call once a third independent condition would be needed', () => {
|
|
233
|
+
// Every independent condition doubles the leaves a full enumeration has
|
|
234
|
+
// to cover; the budget caps how many may combine so a long run of fused
|
|
235
|
+
// conditions doesn't blow up the rewrite.
|
|
236
|
+
expect(
|
|
237
|
+
rewriteWithVariants(
|
|
238
|
+
'<div class={{if outer (concat (if p "a" "b") "-" (if q "x" "y") "-" (if r "1" "2")) "global-thing"}}></div>',
|
|
239
|
+
),
|
|
240
|
+
).to.equal(
|
|
241
|
+
'<div class={{if outer (concat (if p "a" "b") "-" (if q "x" "y") "-" (if r "1" "2")) "global-thing"}}></div>',
|
|
242
|
+
);
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
it('leaves the concat as a call when none of the classes it could produce are in the CSS', () => {
|
|
246
|
+
expect(
|
|
247
|
+
rewrite(
|
|
248
|
+
'<div class={{if outer (concat "z" (if x "-on" "-off")) "global-thing"}}></div>',
|
|
249
|
+
),
|
|
250
|
+
).to.equal(
|
|
251
|
+
'<div class={{if outer (concat "z" (if x "-on" "-off")) "global-thing"}}></div>',
|
|
252
|
+
);
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
it('skips a shadowed concat, leaving it and its nested if alone', () => {
|
|
256
|
+
expect(
|
|
257
|
+
rewriteWithVariants(
|
|
258
|
+
'{{#let x as |concat|}}<div class={{if outer (concat "a" (if x "-on" "-off")) "global-thing"}}></div>{{/let}}',
|
|
259
|
+
),
|
|
260
|
+
).to.equal(
|
|
261
|
+
'{{#let x as |concat|}}<div class={{if outer (concat "a" (if x "-on" "-off")) "global-thing"}}></div>{{/let}}',
|
|
262
|
+
);
|
|
263
|
+
});
|
|
264
|
+
});
|
package/src/lib/rewriteHbs.js
CHANGED
|
@@ -93,6 +93,65 @@ function isWholeClassName(params, index) {
|
|
|
93
93
|
return boundedLeft && boundedRight;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
/**
|
|
97
|
+
* A collapsed `concat`/`if`/`unless` run becomes a StringLiteral or a
|
|
98
|
+
* SubExpression (`(if ...)`), which are the right shape for a helper param
|
|
99
|
+
* but not for an attribute value -- there they need to be a TextNode or
|
|
100
|
+
* MustacheStatement instead.
|
|
101
|
+
*
|
|
102
|
+
* "a-suffix" -> the TextNode a-suffix
|
|
103
|
+
* (if C "a" "b") -> {{if C "a" "b"}}
|
|
104
|
+
*/
|
|
105
|
+
function toAttributeValue(node) {
|
|
106
|
+
if (node.type === 'StringLiteral') return recast.builders.text(node.value);
|
|
107
|
+
|
|
108
|
+
if (node.type === 'SubExpression') {
|
|
109
|
+
return recast.builders.mustache(node.path, node.params, node.hash);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return node;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* How many independent `if`/`unless` conditions may be combined when
|
|
117
|
+
* expanding a concat run into a decision tree. Each one roughly doubles the
|
|
118
|
+
* leaves, so this bounds the blowup rather than the leaf count directly.
|
|
119
|
+
*/
|
|
120
|
+
const MAX_CONDITION_DEPTH = 2;
|
|
121
|
+
|
|
122
|
+
const EMPTY_VALUE = { kind: 'literal', value: '' };
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Concatenate two statically-known values. Two literals just join; a literal
|
|
126
|
+
* against a choice distributes into both of the choice's branches, and two
|
|
127
|
+
* choices nest, doubling the leaves.
|
|
128
|
+
*
|
|
129
|
+
* "a" + "b" -> "ab"
|
|
130
|
+
* "a" + (C ? "x" : "y") -> C ? "ax" : "ay"
|
|
131
|
+
* (C ? "x" : "y") + (D ? "1" : "2") -> C ? (D ? "x1" : "x2") : (D ? "y1" : "y2")
|
|
132
|
+
*/
|
|
133
|
+
function concatValueExprs(left, right) {
|
|
134
|
+
if (left.kind === 'literal' && right.kind === 'literal') {
|
|
135
|
+
return { kind: 'literal', value: left.value + right.value };
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (left.kind === 'choice') {
|
|
139
|
+
return {
|
|
140
|
+
kind: 'choice',
|
|
141
|
+
condition: left.condition,
|
|
142
|
+
whenTrue: concatValueExprs(left.whenTrue, right),
|
|
143
|
+
whenFalse: concatValueExprs(left.whenFalse, right),
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return {
|
|
148
|
+
kind: 'choice',
|
|
149
|
+
condition: right.condition,
|
|
150
|
+
whenTrue: concatValueExprs(left, right.whenTrue),
|
|
151
|
+
whenFalse: concatValueExprs(left, right.whenFalse),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
96
155
|
export function templatePlugin({ classes, tags, attributes, postfix }) {
|
|
97
156
|
let stack = [];
|
|
98
157
|
// scoped-class is a global we allow in hbs
|
|
@@ -131,17 +190,152 @@ export function templatePlugin({ classes, tags, attributes, postfix }) {
|
|
|
131
190
|
return CLASS_BUILDING_HELPERS.has(name) && !isShadowed(name);
|
|
132
191
|
}
|
|
133
192
|
|
|
193
|
+
/**
|
|
194
|
+
* The statically-known values a class-building expression can produce,
|
|
195
|
+
* shaped as the decision tree of the `if`/`unless` conditions involved.
|
|
196
|
+
* `null` means the value isn't pinned down at build time -- either it's a
|
|
197
|
+
* genuine runtime value, or pinning it down would need more conditions
|
|
198
|
+
* than `budget` allows.
|
|
199
|
+
*
|
|
200
|
+
* "a" -> { kind: 'literal', value: 'a' }
|
|
201
|
+
* (if C "a" "b") -> { kind: 'choice', condition: C, whenTrue: ..., whenFalse: ... }
|
|
202
|
+
* (if C "a") -> the same, with whenFalse the empty string
|
|
203
|
+
* this.x -> null, an arbitrary runtime value
|
|
204
|
+
* (someHelper "a") -> null, its contract is opaque
|
|
205
|
+
*
|
|
206
|
+
* `budget.remaining` is shared across one whole enumeration attempt (it is
|
|
207
|
+
* not reset per branch), since sibling conditions multiply leaves exactly
|
|
208
|
+
* as nested ones do.
|
|
209
|
+
*/
|
|
210
|
+
function toValueExpr(node, budget) {
|
|
211
|
+
if (node.type === 'StringLiteral') {
|
|
212
|
+
return { kind: 'literal', value: node.value };
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (node.type !== 'MustacheStatement' && node.type !== 'SubExpression') {
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const name = getValue(node.path);
|
|
220
|
+
|
|
221
|
+
if (!isClassBuilding(name)) return null;
|
|
222
|
+
|
|
223
|
+
if (name === 'concat') {
|
|
224
|
+
let combined = EMPTY_VALUE;
|
|
225
|
+
|
|
226
|
+
for (const param of node.params ?? []) {
|
|
227
|
+
const next = toValueExpr(param, budget);
|
|
228
|
+
|
|
229
|
+
if (!next) return null;
|
|
230
|
+
|
|
231
|
+
combined = concatValueExprs(combined, next);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return combined;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (budget.remaining <= 0) return null;
|
|
238
|
+
|
|
239
|
+
budget.remaining -= 1;
|
|
240
|
+
|
|
241
|
+
const [condition, thenBranch, elseBranch] = node.params ?? [];
|
|
242
|
+
const thenExpr = thenBranch ? toValueExpr(thenBranch, budget) : EMPTY_VALUE;
|
|
243
|
+
const elseExpr = elseBranch ? toValueExpr(elseBranch, budget) : EMPTY_VALUE;
|
|
244
|
+
|
|
245
|
+
if (!thenExpr || !elseExpr) return null;
|
|
246
|
+
|
|
247
|
+
return name === 'unless'
|
|
248
|
+
? { kind: 'choice', condition, whenTrue: elseExpr, whenFalse: thenExpr }
|
|
249
|
+
: { kind: 'choice', condition, whenTrue: thenExpr, whenFalse: elseExpr };
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Rename every leaf of a value tree in one pass, reporting alongside it
|
|
254
|
+
* whether any leaf's value actually changed -- the tree is rebuilt either
|
|
255
|
+
* way, so this is the only point that can tell without walking it twice.
|
|
256
|
+
*/
|
|
257
|
+
function renameValueExpr(expr) {
|
|
258
|
+
if (expr.kind === 'literal') {
|
|
259
|
+
const value = renameClass(expr.value, postfix, classes);
|
|
260
|
+
|
|
261
|
+
return {
|
|
262
|
+
expr: { kind: 'literal', value },
|
|
263
|
+
changed: value !== expr.value,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const whenTrue = renameValueExpr(expr.whenTrue);
|
|
268
|
+
const whenFalse = renameValueExpr(expr.whenFalse);
|
|
269
|
+
|
|
270
|
+
return {
|
|
271
|
+
expr: {
|
|
272
|
+
kind: 'choice',
|
|
273
|
+
condition: expr.condition,
|
|
274
|
+
whenTrue: whenTrue.expr,
|
|
275
|
+
whenFalse: whenFalse.expr,
|
|
276
|
+
},
|
|
277
|
+
changed: whenTrue.changed || whenFalse.changed,
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Turn a value tree into the AST it describes -- a literal for a plain
|
|
283
|
+
* leaf, or nested `if`s reproducing the conditions. A condition reused
|
|
284
|
+
* across sibling branches (two independent `if`s in one concat) appears
|
|
285
|
+
* more than once in the output, exactly as it would if written by hand.
|
|
286
|
+
*/
|
|
287
|
+
function buildValueExprNode(expr) {
|
|
288
|
+
if (expr.kind === 'literal') {
|
|
289
|
+
return recast.builders.literal('StringLiteral', expr.value);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
return recast.builders.sexpr(recast.builders.path('if'), [
|
|
293
|
+
expr.condition,
|
|
294
|
+
buildValueExprNode(expr.whenTrue),
|
|
295
|
+
buildValueExprNode(expr.whenFalse),
|
|
296
|
+
]);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* `concat` fuses its params into one string, so a literal is only a class
|
|
301
|
+
* name of its own when a boundary separates it from its neighbours (see
|
|
302
|
+
* isWholeClassName). When every param's value is statically known and they
|
|
303
|
+
* all fuse, the call produces one of a fixed set of class names, so
|
|
304
|
+
* `concat` has nothing left to join -- the caller replaces the whole call
|
|
305
|
+
* with the literal (no conditions involved) or the `if` expression (one
|
|
306
|
+
* per condition) that reaches each renamed leaf.
|
|
307
|
+
*
|
|
308
|
+
* {{concat "a" " " "b"}} -> two classes, rename each, concat stays
|
|
309
|
+
* {{concat "a" "-suffix"}} -> one class; the call is replaced by it
|
|
310
|
+
* {{concat "a" (if C "-on" "-off")}} -> replaced by {{if C "a-on_pfx" "a-off_pfx"}}
|
|
311
|
+
* {{concat "a" this.x}} -> "a" fuses with an unknown value, so leave it
|
|
312
|
+
*
|
|
313
|
+
* Returns the replacement when the call collapses; otherwise renames
|
|
314
|
+
* whole-class-name params in place and returns nothing.
|
|
315
|
+
*/
|
|
134
316
|
function renameConcatParams(node) {
|
|
135
317
|
const params = node.params ?? [];
|
|
318
|
+
const fuses = params.some(
|
|
319
|
+
(param, index) => !isWholeClassName(params, index),
|
|
320
|
+
);
|
|
321
|
+
|
|
322
|
+
if (fuses) {
|
|
323
|
+
const expr = toValueExpr(node, { remaining: MAX_CONDITION_DEPTH });
|
|
324
|
+
const renamed = expr && renameValueExpr(expr);
|
|
325
|
+
|
|
326
|
+
// Collapsing is only worth the churn if it renamed something -- and
|
|
327
|
+
// only possible at all if every leaf's value was statically known.
|
|
328
|
+
if (renamed?.changed) {
|
|
329
|
+
return buildValueExprNode(renamed.expr);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
136
334
|
|
|
137
335
|
for (const [index, param] of params.entries()) {
|
|
138
336
|
if (!isWholeClassName(params, index)) continue;
|
|
139
337
|
|
|
140
|
-
|
|
141
|
-
param.value = renameClass(param.value, postfix, classes);
|
|
142
|
-
} else {
|
|
143
|
-
renameLiteralClasses(param);
|
|
144
|
-
}
|
|
338
|
+
params[index] = renameLiteralClasses(param);
|
|
145
339
|
}
|
|
146
340
|
}
|
|
147
341
|
|
|
@@ -223,13 +417,17 @@ export function templatePlugin({ classes, tags, attributes, postfix }) {
|
|
|
223
417
|
}
|
|
224
418
|
|
|
225
419
|
/**
|
|
226
|
-
* Rename the string literals whose value reaches the class attribute
|
|
420
|
+
* Rename the string literals whose value reaches the class attribute, and
|
|
421
|
+
* return the node that should stand in this one's place. That's the same
|
|
422
|
+
* node for everything but a `concat` call that collapses to a single
|
|
423
|
+
* literal or `if` expression -- see renameConcatParams.
|
|
227
424
|
*
|
|
228
425
|
* {{if x "a" "b"}} -> both branches
|
|
229
426
|
* {{if (checkAlphabet "a" "b") "a" "b"}} -> the branches, not the condition
|
|
230
427
|
* {{if x (concat "a" " " "b") "c"}} -> concat's own whole-class-name params too
|
|
231
428
|
* {{if x (someHelper "a") "b"}} -> someHelper is opaque, left alone
|
|
232
429
|
* {{concat "a" " " "b"}} -> every param that's a whole class name
|
|
430
|
+
* {{concat "a" "-suffix"}} -> replaced by the renamed literal
|
|
233
431
|
* {{this.fooClass}} -> resolved at runtime, nothing to rename
|
|
234
432
|
*
|
|
235
433
|
* The shadowing checked at each depth is the one in effect at the element
|
|
@@ -238,23 +436,30 @@ export function templatePlugin({ classes, tags, attributes, postfix }) {
|
|
|
238
436
|
* rebound part-way down a class attribute's value.
|
|
239
437
|
*/
|
|
240
438
|
function renameLiteralClasses(node) {
|
|
439
|
+
if (node.type === 'StringLiteral') {
|
|
440
|
+
node.value = renameClass(node.value, postfix, classes);
|
|
441
|
+
|
|
442
|
+
return node;
|
|
443
|
+
}
|
|
444
|
+
|
|
241
445
|
const name = getValue(node.path);
|
|
242
446
|
|
|
243
|
-
if (!isClassBuilding(name)) return;
|
|
447
|
+
if (!isClassBuilding(name)) return node;
|
|
244
448
|
|
|
245
449
|
if (name === 'concat') {
|
|
246
|
-
renameConcatParams(node);
|
|
247
|
-
|
|
248
|
-
return;
|
|
450
|
+
return renameConcatParams(node) ?? node;
|
|
249
451
|
}
|
|
250
452
|
|
|
251
|
-
for (
|
|
252
|
-
if
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
453
|
+
for (const [index, param] of (node.params ?? []).entries()) {
|
|
454
|
+
// `name` is 'if' or 'unless' here ('concat' returned above), so
|
|
455
|
+
// params[0] is the condition itself -- e.g. `x` in `(if x "a" "b")` --
|
|
456
|
+
// not one of the branches, so it's never a class name to rename.
|
|
457
|
+
if (index === 0) continue;
|
|
458
|
+
|
|
459
|
+
node.params[index] = renameLiteralClasses(param);
|
|
257
460
|
}
|
|
461
|
+
|
|
462
|
+
return node;
|
|
258
463
|
}
|
|
259
464
|
|
|
260
465
|
return {
|
|
@@ -278,20 +483,26 @@ export function templatePlugin({ classes, tags, attributes, postfix }) {
|
|
|
278
483
|
|
|
279
484
|
node.value.chars = renamedClass;
|
|
280
485
|
} else if (node.value.type === 'ConcatStatement') {
|
|
281
|
-
for (
|
|
486
|
+
for (const [index, part] of node.value.parts.entries()) {
|
|
282
487
|
if (part.type === 'TextNode' && part.chars) {
|
|
283
488
|
const renamedClass = renameClass(part.chars, postfix, classes);
|
|
284
489
|
|
|
285
490
|
part.chars = renamedClass;
|
|
286
491
|
} else if (part.type === 'MustacheStatement') {
|
|
287
|
-
|
|
492
|
+
node.value.parts[index] = toAttributeValue(
|
|
493
|
+
renameLiteralClasses(part),
|
|
494
|
+
);
|
|
288
495
|
}
|
|
289
496
|
}
|
|
290
497
|
} else if (node.value.type === 'MustacheStatement') {
|
|
291
498
|
// Glimmer parses a quoted attribute value as a ConcatStatement and
|
|
292
499
|
// an unquoted one as a bare MustacheStatement, so `class={{if x
|
|
293
500
|
// "a" "b"}}` lands here rather than in the branch above.
|
|
294
|
-
renameLiteralClasses(node.value);
|
|
501
|
+
const replaced = renameLiteralClasses(node.value);
|
|
502
|
+
|
|
503
|
+
if (replaced.type === 'StringLiteral') node.quoteType = '"';
|
|
504
|
+
|
|
505
|
+
node.value = toAttributeValue(replaced);
|
|
295
506
|
}
|
|
296
507
|
}
|
|
297
508
|
},
|