lion/packages/validate/src/utils/fake-extends-event-target.js
Thijs Louisse 6e81b55e3c feat(validate): new validation api, async validation and more
Co-authored-by: Thomas Allmer <Thomas.Allmer@ing.com>
2019-11-15 16:57:58 +01:00

8 lines
401 B
JavaScript

// TODO: this method has to be removed when EventTarget polyfill is available on IE11
export function fakeExtendsEventTarget(instance) {
const delegate = document.createDocumentFragment();
['addEventListener', 'dispatchEvent', 'removeEventListener'].forEach(funcName => {
// eslint-disable-next-line no-param-reassign
instance[funcName] = (...args) => delegate[funcName](...args);
});
}