angular/projects/ng-devtools-backend/src/lib/utils.ts

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);
};