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
|
||||
|
||||
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';
|
||||
|
||||
export function render(_ctx) {
|
||||
const _component_Comp = _resolveComponent("Comp")
|
||||
const n0 = _createComponentWithFallback(_component_Comp, { modelValue: () => (_ctx.foo),
|
||||
"onUpdate:modelValue": () => _value => (_ctx.foo = _value),
|
||||
modelModifiers: () => ({ trim: true, "bar-baz": true }) }, null, true)
|
||||
modelValueModifiers: () => ({ trim: true, "bar-baz": true }) }, null, true)
|
||||
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(
|
||||
'<Comp v-model.trim.bar-baz="foo" />',
|
||||
)
|
||||
expect(code).toMatchSnapshot()
|
||||
expect(code).contain(
|
||||
`modelModifiers: () => ({ trim: true, "bar-baz": true })`,
|
||||
`modelValueModifiers: () => ({ trim: true, "bar-baz": true })`,
|
||||
)
|
||||
expect(ir.block.dynamic.children[0].operation).toMatchObject({
|
||||
type: IRNodeTypes.CREATE_COMPONENT_NODE,
|
||||
|
|
|
@ -240,9 +240,7 @@ function genModelModifiers(
|
|||
if (!modelModifiers || !modelModifiers.length) return []
|
||||
|
||||
const modifiersKey = key.isStatic
|
||||
? key.content === 'modelValue'
|
||||
? [`modelModifiers`]
|
||||
: [`${key.content}Modifiers`]
|
||||
? [`${key.content}Modifiers`]
|
||||
: ['[', ...genExpression(key, context), ' + "Modifiers"]']
|
||||
|
||||
const modifiersVal = genDirectiveModifiers(modelModifiers)
|
||||
|
|
|
@ -265,7 +265,7 @@ describe('component: emit', () => {
|
|||
const fn2 = vi.fn()
|
||||
render({
|
||||
modelValue: () => null,
|
||||
modelModifiers: () => ({ number: true }),
|
||||
modelValueModifiers: () => ({ number: true }),
|
||||
['onUpdate:modelValue']: () => fn1,
|
||||
foo: () => null,
|
||||
fooModifiers: () => ({ number: true }),
|
||||
|
@ -291,7 +291,7 @@ describe('component: emit', () => {
|
|||
modelValue() {
|
||||
return null
|
||||
},
|
||||
modelModifiers() {
|
||||
modelValueModifiers() {
|
||||
return { trim: true }
|
||||
},
|
||||
['onUpdate:modelValue']() {
|
||||
|
@ -327,7 +327,7 @@ describe('component: emit', () => {
|
|||
modelValue() {
|
||||
return null
|
||||
},
|
||||
modelModifiers() {
|
||||
modelValueModifiers() {
|
||||
return { trim: true, number: true }
|
||||
},
|
||||
['onUpdate:modelValue']() {
|
||||
|
@ -361,7 +361,7 @@ describe('component: emit', () => {
|
|||
modelValue() {
|
||||
return null
|
||||
},
|
||||
modelModifiers() {
|
||||
modelValueModifiers() {
|
||||
return { trim: true }
|
||||
},
|
||||
['onUpdate:modelValue']() {
|
||||
|
|
Loading…
Reference in New Issue