You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe. createEventDispatcher can't not pass through shadow DOM boundaries.
As describe here, Link to lit-element doc, by default, a bubbling custom event fired inside shadow DOM will stop bubbling when it reaches the shadow root.
To make a custom event pass through shadow DOM boundaries, you must set both the composed and bubbles flags to true:
Describe the solution you'd like
Simple solution is like below:
createEventDispatcher({bubbles: true,composed: true,// other custom event options})
Describe alternatives you've considered
Add another function like createCustomDispatcher to handle this case.
Or <svelte:host tag='custom-element' ref={that} attributes={['value', 'label']} />
which also allows you to reflect props to attributes for current custom component.
Or <svelte:options ref={that} />
that allow you to access to this keyword, with it you can use something like: that.dispatchEvent or that.shadowRoot.querySelector()
How important is this feature to you?
I think this is important feature. Since you have no way but using hacky solution with this keyword.
The text was updated successfully, but these errors were encountered:
Another issue i run into is that this will be undefined, Uncaught TypeError: Cannot read property 'dispatchEvent' of undefined when using this.dispatchEvent like:
functionhandleChange(val){this.dispatchEvent(newCustomEvent("select",{detail: val,bubbles: true,composed: true}));}functionhandleItemClick(event){// do something ...handleChange(value);}functionhandleKeyDown(event){if(event.key==="Enter"){// do something ...handleChange(value);}}
The temporary solution is that using dispatchEvent inside handleItemClick and handleKeyDown.
Nice solution could also default composed and bubbles to true when the tag option is used. I believe that is the expected behavior when dispatching an event from a web component using createEventDispatcher but I'm new to Svelte so could be incorrect here.
Is your feature request related to a problem? Please describe.
createEventDispatcher can't not pass through shadow DOM boundaries.
As describe here, Link to lit-element doc, by default, a bubbling custom event fired inside shadow DOM will stop bubbling when it reaches the shadow root.
To make a custom event pass through shadow DOM boundaries, you must set both the
composed
andbubbles
flags totrue
:Currently, you have to hack like this:
Describe the solution you'd like
Simple solution is like below:
Describe alternatives you've considered
Add another function like
createCustomDispatcher
to handle this case.Or
<svelte:host tag='custom-element' ref={that} attributes={['value', 'label']} />
which also allows you to reflect props to attributes for current custom component.
Or
<svelte:options ref={that} />
that allow you to access to
this
keyword, with it you can use something like:that.dispatchEvent
orthat.shadowRoot.querySelector()
How important is this feature to you?
I think this is important feature. Since you have no way but using hacky solution with
this
keyword.The text was updated successfully, but these errors were encountered: