-
Notifications
You must be signed in to change notification settings - Fork 25.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zone.js patchCallbacks with Lightning Web Components #42546
Comments
Hi, |
I had to do a small change to zone.js as attributeChangedCallback is just not a valid lifecycle hook for LWC. It will probably work fine for other web components like LitElement without this change.
|
@ivanovivelin , thank you for the information and the fix, could you provide a reproduce repo so I can check it? |
…hable The `patchCallbacks` is used for patching the `document.registerElement` and `customElements.define`. We explicitly wrap the patching code into try-catch since callbacks may be already patched by other web components frameworks (e.g. LWC), and they make those properties non-writable. This means that patching callback will throw an error `cannot assign to read-only property`. See this code as an example: https://github.com/salesforce/lwc/blob/master/packages/@lwc/engine-core/src/framework/base-bridge-element.ts#L180-L186 We don't want to stop the application rendering if we couldn't patch some callback, e.g. `attributeChangedCallback`. PR Close angular#42546
If you load a LWC into a sample Angular app you should be able to reproduce the issue. You can create a simple LWC app using create-lwc-app and then move the prod bundle JS into the assets of the Angular app and reference the custom element in the angular component.
Remember to import
I can provide a repo if still needed, but I see the PR is raised ? @JiaLiPassion |
…hable (#45400) The `patchCallbacks` is used for patching the `document.registerElement` and `customElements.define`. We explicitly wrap the patching code into try-catch since callbacks may be already patched by other web components frameworks (e.g. LWC), and they make those properties non-writable. This means that patching callback will throw an error `cannot assign to read-only property`. See this code as an example: https://github.com/salesforce/lwc/blob/master/packages/@lwc/engine-core/src/framework/base-bridge-element.ts#L180-L186 We don't want to stop the application rendering if we couldn't patch some callback, e.g. `attributeChangedCallback`. PR Close #42546 PR Close #45400
…hable (angular#45400) The `patchCallbacks` is used for patching the `document.registerElement` and `customElements.define`. We explicitly wrap the patching code into try-catch since callbacks may be already patched by other web components frameworks (e.g. LWC), and they make those properties non-writable. This means that patching callback will throw an error `cannot assign to read-only property`. See this code as an example: https://github.com/salesforce/lwc/blob/master/packages/@lwc/engine-core/src/framework/base-bridge-element.ts#L180-L186 We don't want to stop the application rendering if we couldn't patch some callback, e.g. `attributeChangedCallback`. PR Close angular#42546 PR Close angular#45400
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug Report
Zone.js is incorrectly patching Lightning Web Components hooks when using those within an Angular project.
Description
Using Lightning Web Components in Angular project leads to an exception that comes out of Zone.js. It is trying to patch a attributeChangedCallback in LWC. The name of the method is patchCallbacks
Minimal Reproduction
Exception or Error
Your Environment
Angular Version:
The text was updated successfully, but these errors were encountered: