fix(compiler-vapor): stringify number prop value
This commit is contained in:
parent
4078206e16
commit
0c7817ceed
|
@ -171,7 +171,7 @@ exports[`compile > dynamic root 1`] = `
|
|||
"import { createTextNode as _createTextNode } from 'vue/vapor';
|
||||
|
||||
export function render(_ctx) {
|
||||
const n0 = _createTextNode([1, 2])
|
||||
const n0 = _createTextNode(() => [1, 2])
|
||||
return n0
|
||||
}"
|
||||
`;
|
||||
|
@ -225,7 +225,7 @@ exports[`compile > static + dynamic root 1`] = `
|
|||
"import { createTextNode as _createTextNode } from 'vue/vapor';
|
||||
|
||||
export function render(_ctx) {
|
||||
const n0 = _createTextNode([1, 2, "3", 4, 5, "6", 7, 8, "9", 'A', 'B'])
|
||||
const n0 = _createTextNode(() => [1, 2, "3", 4, 5, "6", 7, 8, "9", 'A', 'B'])
|
||||
return n0
|
||||
}"
|
||||
`;
|
||||
|
|
|
@ -181,6 +181,18 @@ export function render(_ctx) {
|
|||
}"
|
||||
`;
|
||||
|
||||
exports[`compiler v-bind > number value 1`] = `
|
||||
"import { resolveComponent as _resolveComponent, createComponent as _createComponent } from 'vue/vapor';
|
||||
|
||||
export function render(_ctx) {
|
||||
const _component_Comp = _resolveComponent("Comp")
|
||||
const n0 = _createComponent(_component_Comp, [
|
||||
{ depth: () => (0) }
|
||||
], null, true)
|
||||
return n0
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`compiler v-bind > should error if empty expression 1`] = `
|
||||
"import { setInheritAttrs as _setInheritAttrs, template as _template } from 'vue/vapor';
|
||||
const t0 = _template("<div arg></div>")
|
||||
|
|
|
@ -526,4 +526,10 @@ describe('compiler v-bind', () => {
|
|||
expect(code).contains('renderEffect')
|
||||
expect(code).contains('_setAttr(n0, "foo-bar", _ctx.fooBar, true)')
|
||||
})
|
||||
|
||||
test('number value', () => {
|
||||
const { code } = compileWithVBind(`<Comp :depth="0" />`)
|
||||
expect(code).matchSnapshot()
|
||||
expect(code).contains('{ depth: () => (0) }')
|
||||
})
|
||||
})
|
||||
|
|
|
@ -61,11 +61,7 @@ export function getLiteralExpressionValue(
|
|||
exp: SimpleExpressionNode,
|
||||
): number | string | boolean | null {
|
||||
if (exp.ast) {
|
||||
if (
|
||||
['StringLiteral', 'NumericLiteral', 'BigIntLiteral'].includes(
|
||||
exp.ast.type,
|
||||
)
|
||||
) {
|
||||
if (exp.ast.type === 'StringLiteral') {
|
||||
return (exp.ast as StringLiteral | NumericLiteral | BigIntLiteral).value
|
||||
} else if (
|
||||
exp.ast.type === 'TemplateLiteral' &&
|
||||
|
|
Loading…
Reference in New Issue