zone.api.extensions.d.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * @license
  3. * Copyright Google LLC 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.dev/license
  7. */
  8. declare global {
  9. /**
  10. * Additional `EventTarget` methods added by `Zone.js`.
  11. *
  12. * 1. removeAllListeners, remove all event listeners of the given event name.
  13. * 2. eventListeners, get all event listeners of the given event name.
  14. */
  15. interface EventTarget {
  16. /**
  17. *
  18. * Remove all event listeners by name for this event target.
  19. *
  20. * This method is optional because it may not be available if you use `noop zone` when
  21. * bootstrapping Angular application or disable the `EventTarget` monkey patch by `zone.js`.
  22. *
  23. * If the `eventName` is provided, will remove event listeners of that name.
  24. * If the `eventName` is not provided, will remove all event listeners associated with
  25. * `EventTarget`.
  26. *
  27. * @param eventName the name of the event, such as `click`. This parameter is optional.
  28. */
  29. removeAllListeners?(eventName?: string): void;
  30. /**
  31. *
  32. * Retrieve all event listeners by name.
  33. *
  34. * This method is optional because it may not be available if you use `noop zone` when
  35. * bootstrapping Angular application or disable the `EventTarget` monkey patch by `zone.js`.
  36. *
  37. * If the `eventName` is provided, will return an array of event handlers or event listener
  38. * objects of the given event.
  39. * If the `eventName` is not provided, will return all listeners.
  40. *
  41. * @param eventName the name of the event, such as click. This parameter is optional.
  42. */
  43. eventListeners?(eventName?: string): EventListenerOrEventListenerObject[];
  44. }
  45. }
  46. export {};