mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
25 lines
621 B
TypeScript
25 lines
621 B
TypeScript
export const runOutsideAngular = (f: () => any): void => {
|
|
const w = window as any;
|
|
if (!w.Zone || !w.Zone.current) {
|
|
f();
|
|
return;
|
|
}
|
|
if (w.Zone.current._name !== 'angular') {
|
|
w.Zone.current.run(f);
|
|
return;
|
|
}
|
|
w.Zone.current._parent.run(f);
|
|
};
|
|
|
|
export const componentMetadata = (instance: any) => instance.constructor.ɵcmp;
|
|
|
|
export const isCustomElement = (node: Node) => {
|
|
if (typeof customElements === 'undefined') {
|
|
return false;
|
|
}
|
|
if (!(node instanceof HTMLElement)) {
|
|
return false;
|
|
}
|
|
const tagName = node.tagName.toLowerCase();
|
|
return !!customElements.get(tagName);
|
|
};
|