diff --git a/js/src/dom/event-handler.js b/js/src/dom/event-handler.js index a31ed333c9..413aa6e284 100644 --- a/js/src/dom/event-handler.js +++ b/js/src/dom/event-handler.js @@ -20,7 +20,7 @@ const customEvents = { mouseenter: 'mouseover', mouseleave: 'mouseout' } -const customEventsRegex = /^(mouseenter|mouseleave)/i + const nativeEvents = new Set([ 'click', 'dblclick', @@ -150,7 +150,7 @@ function addHandler(element, originalTypeEvent, handler, delegationFunction, one // in case of mouseenter or mouseleave wrap the handler within a function that checks for its DOM position // this prevents the handler from being dispatched the same way as mouseover or mouseout does - if (customEventsRegex.test(originalTypeEvent)) { + if (originalTypeEvent in customEvents) { const wrapFunction = fn => { return function (event) { if (!event.relatedTarget || (event.relatedTarget !== event.delegateTarget && !event.delegateTarget.contains(event.relatedTarget))) {