salesforce / lwc

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

fix: allow lazy-disabling native lifecycle #4350

Closed nolanlawson closed 6 days ago

nolanlawson commented 6 days ago

Details

In some environments, the lwcRuntimeFlags.DISABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE flag is lazily set to true, after the engine has initialized but before a component has rendered. This worked okay in LWC v6 through LWC v7.0.0, but broke in LWC v7.0.1 due to #4316, which caused all DOM monkey-patching to only occur at initialization time.

So lazily-setting the flag effectively puts you in a broken state, where the component is trying to run in synthetic lifecycle mode, but connectedCallback/disconnectedCallback never fires because the monkey-patching is never put in place.

This PR restores the previous behavior, where the monkey-patching can occur dynamically at the time the component is rendered.

Does this pull request introduce a breaking change?

Does this pull request introduce an observable change?

Yeah but it's observable in a way that restores the previous (250-like) behavior.

GUS work item

W-16153421