mirror of https://github.com/vuejs/core.git
feat: use for vapor
This commit is contained in:
parent
8b7a035d14
commit
9df9281b50
|
@ -1,13 +1,13 @@
|
||||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||||
|
|
||||||
exports[`compiler: vModel transform > component > v-model for component should generate modelModifiers 1`] = `
|
exports[`compiler: vModel transform > component > v-model for component should generate modelValueModifiers 1`] = `
|
||||||
"import { resolveComponent as _resolveComponent, createComponentWithFallback as _createComponentWithFallback } from 'vue';
|
"import { resolveComponent as _resolveComponent, createComponentWithFallback as _createComponentWithFallback } from 'vue';
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const _component_Comp = _resolveComponent("Comp")
|
const _component_Comp = _resolveComponent("Comp")
|
||||||
const n0 = _createComponentWithFallback(_component_Comp, { modelValue: () => (_ctx.foo),
|
const n0 = _createComponentWithFallback(_component_Comp, { modelValue: () => (_ctx.foo),
|
||||||
"onUpdate:modelValue": () => _value => (_ctx.foo = _value),
|
"onUpdate:modelValue": () => _value => (_ctx.foo = _value),
|
||||||
modelModifiers: () => ({ trim: true, "bar-baz": true }) }, null, true)
|
modelValueModifiers: () => ({ trim: true, "bar-baz": true }) }, null, true)
|
||||||
return n0
|
return n0
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -266,13 +266,13 @@ describe('compiler: vModel transform', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test('v-model for component should generate modelModifiers', () => {
|
test('v-model for component should generate modelValueModifiers', () => {
|
||||||
const { code, ir } = compileWithVModel(
|
const { code, ir } = compileWithVModel(
|
||||||
'<Comp v-model.trim.bar-baz="foo" />',
|
'<Comp v-model.trim.bar-baz="foo" />',
|
||||||
)
|
)
|
||||||
expect(code).toMatchSnapshot()
|
expect(code).toMatchSnapshot()
|
||||||
expect(code).contain(
|
expect(code).contain(
|
||||||
`modelModifiers: () => ({ trim: true, "bar-baz": true })`,
|
`modelValueModifiers: () => ({ trim: true, "bar-baz": true })`,
|
||||||
)
|
)
|
||||||
expect(ir.block.dynamic.children[0].operation).toMatchObject({
|
expect(ir.block.dynamic.children[0].operation).toMatchObject({
|
||||||
type: IRNodeTypes.CREATE_COMPONENT_NODE,
|
type: IRNodeTypes.CREATE_COMPONENT_NODE,
|
||||||
|
|
|
@ -240,9 +240,7 @@ function genModelModifiers(
|
||||||
if (!modelModifiers || !modelModifiers.length) return []
|
if (!modelModifiers || !modelModifiers.length) return []
|
||||||
|
|
||||||
const modifiersKey = key.isStatic
|
const modifiersKey = key.isStatic
|
||||||
? key.content === 'modelValue'
|
? [`${key.content}Modifiers`]
|
||||||
? [`modelModifiers`]
|
|
||||||
: [`${key.content}Modifiers`]
|
|
||||||
: ['[', ...genExpression(key, context), ' + "Modifiers"]']
|
: ['[', ...genExpression(key, context), ' + "Modifiers"]']
|
||||||
|
|
||||||
const modifiersVal = genDirectiveModifiers(modelModifiers)
|
const modifiersVal = genDirectiveModifiers(modelModifiers)
|
||||||
|
|
|
@ -265,7 +265,7 @@ describe('component: emit', () => {
|
||||||
const fn2 = vi.fn()
|
const fn2 = vi.fn()
|
||||||
render({
|
render({
|
||||||
modelValue: () => null,
|
modelValue: () => null,
|
||||||
modelModifiers: () => ({ number: true }),
|
modelValueModifiers: () => ({ number: true }),
|
||||||
['onUpdate:modelValue']: () => fn1,
|
['onUpdate:modelValue']: () => fn1,
|
||||||
foo: () => null,
|
foo: () => null,
|
||||||
fooModifiers: () => ({ number: true }),
|
fooModifiers: () => ({ number: true }),
|
||||||
|
@ -291,7 +291,7 @@ describe('component: emit', () => {
|
||||||
modelValue() {
|
modelValue() {
|
||||||
return null
|
return null
|
||||||
},
|
},
|
||||||
modelModifiers() {
|
modelValueModifiers() {
|
||||||
return { trim: true }
|
return { trim: true }
|
||||||
},
|
},
|
||||||
['onUpdate:modelValue']() {
|
['onUpdate:modelValue']() {
|
||||||
|
@ -327,7 +327,7 @@ describe('component: emit', () => {
|
||||||
modelValue() {
|
modelValue() {
|
||||||
return null
|
return null
|
||||||
},
|
},
|
||||||
modelModifiers() {
|
modelValueModifiers() {
|
||||||
return { trim: true, number: true }
|
return { trim: true, number: true }
|
||||||
},
|
},
|
||||||
['onUpdate:modelValue']() {
|
['onUpdate:modelValue']() {
|
||||||
|
@ -361,7 +361,7 @@ describe('component: emit', () => {
|
||||||
modelValue() {
|
modelValue() {
|
||||||
return null
|
return null
|
||||||
},
|
},
|
||||||
modelModifiers() {
|
modelValueModifiers() {
|
||||||
return { trim: true }
|
return { trim: true }
|
||||||
},
|
},
|
||||||
['onUpdate:modelValue']() {
|
['onUpdate:modelValue']() {
|
||||||
|
|
Loading…
Reference in New Issue