fix(zone.js): swallow the error when the element callback is not patchable#45400
fix(zone.js): swallow the error when the element callback is not patchable#45400arturovt wants to merge 1 commit intoangular:masterfrom
Conversation
…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
JiaLiPassion
left a comment
There was a problem hiding this comment.
@arturovt , thank you for the PR, is that possible to check the propertyDescriptor is non-configurable instead of try/catch?
Hey, unfortunately, the code that throws is this one: else if (prototype[callback]) {
prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source);
}The descriptor is |
|
Got it, and is that possible to load |
Sure. The thing is the |
|
It looks like this might be ready for merge @arturovt @JiaLiPassion? |
|
@dylhunn , yes, this one is ready for merge, thank you. |
|
This PR was merged into the repository by commit 4ea70e3. |
…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
|
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. |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What is the current behavior?
Issue Number: #42546
Does this PR introduce a breaking change?