|
@@ -7,7 +7,9 @@ import {
|
|
|
h,
|
|
h,
|
|
|
nodeOps,
|
|
nodeOps,
|
|
|
toHandlers,
|
|
toHandlers,
|
|
|
- nextTick
|
|
|
|
|
|
|
+ nextTick,
|
|
|
|
|
+ ref,
|
|
|
|
|
+ watchEffect
|
|
|
} from '@vue/runtime-test'
|
|
} from '@vue/runtime-test'
|
|
|
import { isEmitListener } from '../src/componentEmits'
|
|
import { isEmitListener } from '../src/componentEmits'
|
|
|
|
|
|
|
@@ -431,4 +433,36 @@ describe('component: emit', () => {
|
|
|
await nextTick()
|
|
await nextTick()
|
|
|
expect(fn).not.toHaveBeenCalled()
|
|
expect(fn).not.toHaveBeenCalled()
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
|
|
+ test('should not track during listener execution', async () => {
|
|
|
|
|
+ const counter = ref(0)
|
|
|
|
|
+ const Comp = defineComponent({
|
|
|
|
|
+ emits: ['interaction'],
|
|
|
|
|
+ setup(props, { emit }) {
|
|
|
|
|
+ const doEmit = ref(true)
|
|
|
|
|
+ watchEffect(() => {
|
|
|
|
|
+ if (doEmit.value) emit('interaction')
|
|
|
|
|
+ })
|
|
|
|
|
+ return () => h('div')
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ const el = nodeOps.createElement('div')
|
|
|
|
|
+ render(
|
|
|
|
|
+ h(Comp, {
|
|
|
|
|
+ onInteraction: async () => {
|
|
|
|
|
+ if (counter.value < 5) {
|
|
|
|
|
+ await nextTick()
|
|
|
|
|
+ counter.value++
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }),
|
|
|
|
|
+ el
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ await nextTick()
|
|
|
|
|
+ await nextTick()
|
|
|
|
|
+ await nextTick()
|
|
|
|
|
+
|
|
|
|
|
+ expect(counter.value).toBe(1)
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|