Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Element, Emit CustomEvent, allow bubbles #7605

Closed
NielsJorck opened this issue Jan 30, 2023 · 2 comments
Closed

Custom Element, Emit CustomEvent, allow bubbles #7605

NielsJorck opened this issue Jan 30, 2023 · 2 comments

Comments

@NielsJorck
Copy link

What problem does this feature solve?

The current implementation of Custom Elements lets defined emits dispatch a CustomEvent with the arg put in details.
However there is no way to allow these events to bubble.

Current code snippet from the sourcecode:

new CustomEvent(event, {
  detail: args
})

As described in the documentation here: https://vuejs.org/guide/extras/web-components.html#events

However there is no way to define the bubbles property in the CustomEvent.

What does the proposed API look like?

It could be as simple as checking if there is a property called bubbles in the args and pass that in, otherwise default to false.

@NielsJorck NielsJorck added the ✨ feature request New feature or request label Jan 30, 2023
@atlemagnussen
Copy link

If we could easily access the root html element in SFC we might not need to use Vue's special event handling

yyx990803 added a commit that referenced this issue Aug 3, 2024
In a custom element created via `defineCustomElement`, if the first
event argument is an object, it will be used as the options object
for the emitted CustomEvent. The entire argument list is still exposed
via the CustomEvent's `detail` property.

```js
emit('event', { bubbles: true })
```

close #7605
@yyx990803
Copy link
Member

closed via e181bff (to be shipped in 3.5)

@github-actions github-actions bot locked and limited conversation to collaborators Aug 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants