parent
08f504c1b7
commit
18911abb91
@ -1,6 +1,5 @@
|
|||||||
import { ErrorCodes, callWithErrorHandling } from './errorHandling'
|
import { ErrorCodes, callWithErrorHandling } from './errorHandling'
|
||||||
import { isArray } from '@vue/shared'
|
import { isArray } from '@vue/shared'
|
||||||
import { ComponentPublicInstance } from './componentPublicInstance'
|
|
||||||
import { ComponentInternalInstance, getComponentName } from './component'
|
import { ComponentInternalInstance, getComponentName } from './component'
|
||||||
import { warn } from './warning'
|
import { warn } from './warning'
|
||||||
import { ReactiveEffect } from '@vue/reactivity'
|
import { ReactiveEffect } from '@vue/reactivity'
|
||||||
@ -39,9 +38,9 @@ let currentPreFlushParentJob: SchedulerJob | null = null
|
|||||||
const RECURSION_LIMIT = 100
|
const RECURSION_LIMIT = 100
|
||||||
type CountMap = Map<SchedulerJob | SchedulerCb, number>
|
type CountMap = Map<SchedulerJob | SchedulerCb, number>
|
||||||
|
|
||||||
export function nextTick(
|
export function nextTick<T = void>(
|
||||||
this: ComponentPublicInstance | void,
|
this: T,
|
||||||
fn?: () => void
|
fn?: (this: T) => void
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const p = currentFlushPromise || resolvedPromise
|
const p = currentFlushPromise || resolvedPromise
|
||||||
return fn ? p.then(this ? fn.bind(this) : fn) : p
|
return fn ? p.then(this ? fn.bind(this) : fn) : p
|
||||||
|
@ -905,6 +905,25 @@ describe('emits', () => {
|
|||||||
expectError(this.$emit('input'))
|
expectError(this.$emit('input'))
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
expectError(this.$emit('input', 1))
|
expectError(this.$emit('input', 1))
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
// #3599
|
||||||
|
this.$nextTick(function() {
|
||||||
|
// this should be bound to this instance
|
||||||
|
|
||||||
|
this.$emit('click', 1)
|
||||||
|
this.$emit('input', 'foo')
|
||||||
|
// @ts-expect-error
|
||||||
|
expectError(this.$emit('nope'))
|
||||||
|
// @ts-expect-error
|
||||||
|
expectError(this.$emit('click'))
|
||||||
|
// @ts-expect-error
|
||||||
|
expectError(this.$emit('click', 'foo'))
|
||||||
|
// @ts-expect-error
|
||||||
|
expectError(this.$emit('input'))
|
||||||
|
// @ts-expect-error
|
||||||
|
expectError(this.$emit('input', 1))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user