salesforce / lwc

⚡️ LWC - A Blazing Fast, Enterprise-Grade Web Components Foundation
https://lwc.dev
Other
1.59k stars 386 forks source link

Allow components to opt in to native custom element lifecycle #4252

Open nolanlawson opened 1 month ago

nolanlawson commented 1 month ago

Edit: there is now an RFC.

4249 indicates that it may not be safe to compose native and synthetic lifecycle components together. For that reason, we should perhaps treat it similarly to native vs synthetic shadow DOM, and allow components to opt-in instead. E.g.:

export default class extends LightningElement {
  static lifecycleSupportMode = 'native' // native
  static lifecycleSupportMode = 'reset' // synthetic
}

There is an open question about whether this should affect child trees, similar to native shadow DOM when using shadowSupportMode. It's not clear that this would help much, since #4249 is more around slotting rather than parent-child relationships (although the same issues would also apply to parent-child relationships).

Related: #3198