Event bubbling is quite strange in render function #9519
jamie-mttk
started this conversation in
General Discussions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
To demo this issue ,I create two vue files as below
Child.vue is rendered by vue3 render feature. ElPagination is element plus pagination component.
`<script lang="ts">
import { h, resolveComponent } from 'vue'
export default {
setup() {
return ()=>h(resolveComponent('ElPagination'), {
layout: "prev, pager, next",
total: 50,
'onCurrentChange': function () {
console.log("current-change inside", ...arguments);
},
'onClick': function () {
console.log("click inside", ...arguments);
},
})
}
}
</script>`
And an index.vue is to call Child.vue
`
<script lang="ts" setup> import Child from './Child.vue'; </script><Child
@CurrentChange="function(){console.log('Current change outside', ...arguments)}"
@click="function(){console.log('Click outside', ...arguments)}"
`
From my understanding the outside event can NOT be triggered, but the result is both inside and outside functions are triggered.
If I change the onCurrentChange in Child.vue to onCurrent-change (This feature is not comform to vue3 manual), only the inside function is triggered, the event is stop bubbling as expected.
If I change the onClick in Child.vue to onClickStop (This feature IS comform to vue3 manual), the inside function can not be triggered which means the event is not captured in Child.vue. I try to use withModifiers as below it does not work well, the event is not stop bubbling .
onClick:withModifiers(()=> { console.log('CLICK ... inside', arguments) }, ['stop']),
So it is quite strange, it looks like vue3 has different behavior for one word event name and two words event name in render funtion.
And there is NOT a way to stop event bubbling in render function.
Beta Was this translation helpful? Give feedback.
All reactions