lwc
lwc copied to clipboard
Use native `connectedCallback`/`disconnectedCallback` lifecycle hooks
We use non-standard mechanisms to trigger connectedCallback/disconnectedCallback. We should just use the native mechanism instead.
https://github.com/salesforce/lwc/blob/551f6349421f3cfaf4e8c4a8d3d393b7549bb0ab/packages/@lwc/engine-dom/src/apis/create-element.ts#L50-L72
This has implications for backwards compat, because the timing and other subtleties will be different.
Related: https://github.com/salesforce/lwc/issues/2609, https://github.com/salesforce/lwc/issues/1102, https://github.com/salesforce/lwc/pull/2709
Also related: #2986 which added a flag, without making the flag true by default.
This issue has been linked to a new work item: W-12114614
Reopening as native custom element lifecycle had to be reverted in the Salesforce Lightning Platform due to breaking changes, although it is still rolled out for pure OSS consumers.