diff --git a/src/utils/dom.js b/src/utils/dom.js index 2d3bfac14..b8cc250d6 100644 --- a/src/utils/dom.js +++ b/src/utils/dom.js @@ -74,14 +74,15 @@ export const createEl = (tag, attrs = '', child) => { // hack seems the only way export const createCustomEvent = (e, cls) => { let oEvent; + const { type } = e; try { - oEvent = new window[cls](e.type, e); - } catch (e) { + oEvent = new window[cls](type, e); + } catch (err) { oEvent = document.createEvent(cls); - oEvent.initEvent(e.type, true, true); + oEvent.initEvent(type, true, true); } oEvent._parentEvent = e; - if (e.type.startsWith('key')) { + if (type.indexOf('key') === 0) { oEvent.keyCodeVal = e.keyCode; ['keyCode', 'which'].forEach(prop => { Object.defineProperty(oEvent, prop, {