Reputation: 37268
I tested and it works, but I'm not sure if it's my browser. Does babel support addEventListener
with 3rd argument as an object? I want to set once:true
:
https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
target.addEventListener(type, listener[, options]);
options Optional
An options object that specifies characteristics about the event listener. The available options are:
capture: A Boolean that indicates that events of this type will be dispatched to the registered listener before being dispatched to any EventTarget beneath it in the DOM tree.
once: A Boolean indicating that the listener should be invoked at most once after being added. If it is true, the listener would be removed automatically when it is invoked.
passive: A Boolean indicating that the listener will never call preventDefault(). If it does, the user agent should ignore it and generate a console warning.
Upvotes: 2
Views: 1703
Reputation: 161517
Babel doesn't hand things like this. Babel attempts to make standard ES6+ syntax and library functionality work in older browsers. The DOM API, of which addEventListener
is part, is not defined by the ECMAScript language specification, so it is unrelated to Babel.
You'd want to load a DOM polyfill like https://github.com/WebReflection/dom4.
Upvotes: 3