HTML should see custom events that are defined on a LWC's superclass.

Issue #2196 resolved
Darrion created an issue

Conditions:

  • Create an LWC superComponent
  • Add the following:

    • superEvent() { this.dispatchEvent(new CustomEvent('superevent')); }
  • Create an LWC subComponent, and make the class extend superComponent

  • Add the following:
subEvent() { this.dispatchEvent(new CustomEvent('subevent')); }

handleSubEvent(evt) { console.log('Sub'); }

handleSuperEvent(evt) { console.log('Super'); }
  • Create a demo component demoComponent:

    • Add the subclass component to the HTML:
    • <c-sub-component onsubevent={handleSubEvent} onsuperevent={handleSuperEvent}></c-sub-component>

Current Functionality:

  • ‘onsubevent’ is recognised
  • ‘onsuperevent’ is highlighted with warning ‘Attribute onsuperevent is not allowed here’

Enhancement request:

  • ‘onsuperevent’ is recognised

Comments (4)

  1. Scott Wells repo owner

    Thanks for reporting. This was a very simple oversight where all other attribute discovery based on the controller file would occur taking into considering the inheritance hierarchy, but the search for raised CustomEvents would not. I’ve committed a fix for the next build.

  2. Log in to comment