shadydom.ts 1.1 KB

123456789101112131415161718192021222324
  1. /**
  2. * @license
  3. * Copyright Google Inc. All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://angular.io/license
  7. */
  8. Zone.__load_patch('shadydom', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
  9. // https://github.com/angular/zone.js/issues/782
  10. // in web components, shadydom will patch addEventListener/removeEventListener of
  11. // Node.prototype and WindowPrototype, this will have conflict with zone.js
  12. // so zone.js need to patch them again.
  13. const windowPrototype = Object.getPrototypeOf(window);
  14. if (windowPrototype && windowPrototype.hasOwnProperty('addEventListener')) {
  15. (windowPrototype as any)[Zone.__symbol__('addEventListener')] = null;
  16. (windowPrototype as any)[Zone.__symbol__('removeEventListener')] = null;
  17. api.patchEventTarget(global, [windowPrototype]);
  18. }
  19. if (Node.prototype.hasOwnProperty('addEventListener')) {
  20. (Node.prototype as any)[Zone.__symbol__('addEventListener')] = null;
  21. (Node.prototype as any)[Zone.__symbol__('removeEventListener')] = null;
  22. api.patchEventTarget(global, [Node.prototype]);
  23. }
  24. });