webapis-shadydom.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. 'use strict';
  2. /**
  3. * @license Angular v<unknown>
  4. * (c) 2010-2025 Google LLC. https://angular.io/
  5. * License: MIT
  6. */
  7. function patchShadyDom(Zone) {
  8. Zone.__load_patch('shadydom', (global, Zone, api) => {
  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 HTMLSlotElement = global.HTMLSlotElement;
  14. const prototypes = [
  15. Object.getPrototypeOf(window),
  16. Node.prototype,
  17. Text.prototype,
  18. Element.prototype,
  19. HTMLElement.prototype,
  20. HTMLSlotElement && HTMLSlotElement.prototype,
  21. DocumentFragment.prototype,
  22. Document.prototype,
  23. ];
  24. prototypes.forEach(function (proto) {
  25. if (proto && proto.hasOwnProperty('addEventListener')) {
  26. proto[Zone.__symbol__('addEventListener')] = null;
  27. proto[Zone.__symbol__('removeEventListener')] = null;
  28. api.patchEventTarget(global, api, [proto]);
  29. }
  30. });
  31. });
  32. }
  33. patchShadyDom(Zone);