backwards-compatibility-DHR38MsD.mjs 1.1 KB

12345678910111213141516171819202122232425
  1. import { VERSION } from '@angular/core';
  2. // TODO(crisbeto): remove this function when making breaking changes for v20.
  3. /**
  4. * Binds an event listener with specific options in a backwards-compatible way.
  5. * This function is necessary, because `Renderer2.listen` only supports listener options
  6. * after 19.1 and during the v19 period we support any 19.x version.
  7. * @docs-private
  8. */
  9. function _bindEventWithOptions(renderer, target, eventName, callback, options) {
  10. const major = parseInt(VERSION.major);
  11. const minor = parseInt(VERSION.minor);
  12. // Event options in `listen` are only supported in 19.1 and beyond.
  13. // We also allow 0.0.x, because that indicates a build at HEAD.
  14. if (major > 19 || (major === 19 && minor > 0) || (major === 0 && minor === 0)) {
  15. return renderer.listen(target, eventName, callback, options);
  16. }
  17. target.addEventListener(eventName, callback, options);
  18. return () => {
  19. target.removeEventListener(eventName, callback, options);
  20. };
  21. }
  22. export { _bindEventWithOptions as _ };
  23. //# sourceMappingURL=backwards-compatibility-DHR38MsD.mjs.map