Skip to content

@Listen(slotchange) not triggered #2770

Closed
@dellfort

Description

@dellfort

Stencil version:

 @stencil/core@2.3.0

I'm submitting a:
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/

Current behavior:
@listen('slotchange') is not triggered when slot content changes

Expected behavior:
@listen('slotchange') is triggered when slot content changes

Steps to reproduce:
Apply a slotchange Listen decorator to a component with slot. Change slotted content.
Apply a slotchange EventListener directly to the slot on omponentDidLoad to see that the event is being fired.
-->

Related code:

    @Listen('slotchange')
    handleSlotChange(evt) {
        console.log('slot changed', evt);
    }

    @Listen('click')
    handleClick(evt) {
        console.log('being clicked', evt);
    }

    componentDidLoad() {
       this.el.shadowRoot.querySelector('slot').addEventListener('slotchange', (evt: any) => {
         console.log('slot changed', evt);
       })
    }

    render() {
        return (
            <Fragment>
                <span>OK</span>
                <slot />
            </Fragment>               
        );
    }
     <button onClick={ ()=> { document.getElementById('date1').innerHTML = "2020-07-05" } }>change</button><br />
     <c-mycomponent id="date1" >2020-06-05</c-mycomponent>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions