Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

functions.js 958B

12345678910111213141516171819202122232425
  1. /**
  2. * Prevents further propagation of the events to be handler by a specific event
  3. * handler/listener in the capturing and bubbling phases.
  4. *
  5. * @param {Function} eventHandler - The event handler/listener which handles
  6. * events that need to be stopped from propagating.
  7. * @returns {Function} An event handler/listener to be used in place of the
  8. * specified eventHandler in order to stop the events from propagating.
  9. */
  10. export function stopEventPropagation(eventHandler) {
  11. return ev => {
  12. const r = eventHandler(ev);
  13. // React Native does not propagate the press event so, for the sake of
  14. // cross-platform compatibility, stop the propagation on Web as well.
  15. // Additionally, use feature checking in order to deal with browser
  16. // differences.
  17. if (ev && ev.stopPropagation) {
  18. ev.stopPropagation();
  19. ev.preventDefault && ev.preventDefault();
  20. }
  21. return r;
  22. };
  23. }