Skip to content

Commit e653e77

Browse files
committed
feat(compiler): defaults prop.value to true when it is null
1 parent 6aa56ac commit e653e77

File tree

3 files changed

+175
-142
lines changed

3 files changed

+175
-142
lines changed

packages/compiler/src/transforms/transformElement.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
createSimpleExpression,
23
isValidHTMLNesting,
34
type SimpleExpressionNode,
45
} from '@vue/compiler-dom'
@@ -271,7 +272,7 @@ function transformProp(
271272
value:
272273
prop.value && prop.value.type === 'StringLiteral'
273274
? resolveSimpleExpression(prop.value.value, true, prop.value.loc!)
274-
: EMPTY_EXPRESSION,
275+
: createSimpleExpression('true', false),
275276
}
276277
}
277278

packages/compiler/test/transforms/__snapshots__/vBind.spec.ts.snap

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,37 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3+
exports[`compiler v-bind > .attr modifier 1`] = `
4+
"
5+
const n0 = t0()
6+
_renderEffect(() => _setAttr(n0, "foo-bar", id))
7+
return n0
8+
"
9+
`;
10+
11+
exports[`compiler v-bind > .camel modifier 1`] = `
12+
"
13+
const n0 = t0()
14+
_renderEffect(() => _setProp(n0, "fooBar", id))
15+
return n0
16+
"
17+
`;
18+
19+
exports[`compiler v-bind > .prop modifier 1`] = `
20+
"
21+
const n0 = t0()
22+
_renderEffect(() => _setDOMProp(n0, "fooBar", id))
23+
return n0
24+
"
25+
`;
26+
27+
exports[`compiler v-bind > no expression 1`] = `
28+
"
29+
const n0 = t0()
30+
_setProp(n0, "id", true)
31+
return n0
32+
"
33+
`;
34+
335
exports[`compiler v-bind > with constant value 1`] = `
436
"
537
const n0 = t0()

0 commit comments

Comments
 (0)