Skip to content

Commit

Permalink
test: test for events when component updating (#7896)
Browse files Browse the repository at this point in the history
test for #5517
  • Loading branch information
iwusong authored Jun 4, 2024
1 parent 4caabf2 commit be1e9bf
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions packages/runtime-core/__tests__/componentProps.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -749,4 +749,39 @@ describe('component props', () => {
expect(`Invalid prop name: "ref"`).toHaveBeenWarned()
expect(`Invalid prop name: "$foo"`).toHaveBeenWarned()
})

// #5517
test('events should not be props when component updating', async () => {
let props: any
function eventHandler() {}
const foo = ref(1)

const Child = defineComponent({
setup(_props) {
props = _props
},
emits: ['event'],
props: ['foo'],
template: `<div>{{ foo }}</div>`,
})

const Comp = defineComponent({
setup() {
return {
foo,
eventHandler,
}
},
components: { Child },
template: `<Child @event="eventHandler" :foo="foo" />`,
})

const root = document.createElement('div')
domRender(h(Comp), root)
expect(props).not.toHaveProperty('onEvent')

foo.value++
await nextTick()
expect(props).not.toHaveProperty('onEvent')
})
})

0 comments on commit be1e9bf

Please sign in to comment.