Browse Source
Merge pull request #3550 from dungeonfog/fix-mouseevents
Only patch keyboard events when creating a custom event.
pull/3670/head
Artur Arseniev
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
9 additions and
7 deletions
-
src/utils/dom.js
|
|
|
@ -80,15 +80,17 @@ export const createCustomEvent = (e, cls) => { |
|
|
|
oEvent = document.createEvent(cls); |
|
|
|
oEvent.initEvent(e.type, true, true); |
|
|
|
} |
|
|
|
oEvent.keyCodeVal = e.keyCode; |
|
|
|
oEvent._parentEvent = e; |
|
|
|
['keyCode', 'which'].forEach(prop => { |
|
|
|
Object.defineProperty(oEvent, prop, { |
|
|
|
get() { |
|
|
|
return this.keyCodeVal; |
|
|
|
} |
|
|
|
if (e.type.startsWith('key')) { |
|
|
|
oEvent.keyCodeVal = e.keyCode; |
|
|
|
['keyCode', 'which'].forEach(prop => { |
|
|
|
Object.defineProperty(oEvent, prop, { |
|
|
|
get() { |
|
|
|
return this.keyCodeVal; |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
return oEvent; |
|
|
|
}; |
|
|
|
|
|
|
|
|