mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
This commit updates the implementation of the `customElements` patch and also patches FACE callbacks (`formAssociatedCallback`, `formDisabledCallback`, `formResetCallback` and `formStateRestoreCallback`). This now allows invoking those callbacks in the same zone where the custom element has been defined. PR Close #50686
23 lines
882 B
TypeScript
23 lines
882 B
TypeScript
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
export function patchCustomElements(_global: any, api: _ZonePrivate) {
|
|
const {isBrowser, isMix} = api.getGlobalObjects()!;
|
|
if ((!isBrowser && !isMix) || !_global['customElements'] || !('customElements' in _global)) {
|
|
return;
|
|
}
|
|
|
|
// https://html.spec.whatwg.org/multipage/custom-elements.html#concept-custom-element-definition-lifecycle-callbacks
|
|
const callbacks = [
|
|
'connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback',
|
|
'formAssociatedCallback', 'formDisabledCallback', 'formResetCallback',
|
|
'formStateRestoreCallback'
|
|
];
|
|
|
|
api.patchCallbacks(api, _global.customElements, 'customElements', 'define', callbacks);
|
|
}
|