Fix bug for MouseEventConstructor compatible with webkit-3.0

This commit is contained in:
xiaolou86 2018-03-12 21:18:04 +08:00
parent e9118e3bda
commit 113eb8fa07
1 changed files with 12 additions and 1 deletions

View File

@ -27,7 +27,18 @@ function _captureProxy(e) {
if (_captureRecursion) return;
// Clone the event as we cannot dispatch an already dispatched event
var newEv = new e.constructor(e.type, e);
var newEv = null;
try {
newEv = new e.constructor(e.type, e);
} catch (error) {
// Compatible with webkit-3.0 for MouseEventConstructor
if ( Object.prototype.toString.call(e) === '[object MouseEvent]') {
newEv = document.createEvent("MouseEvent");
newEv.initMouseEvent(e.type, e.bubbles, e.cancelable, e.view, e.detail, e.screenX, e.screenY, e.clientX, e.clientY, e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, e.button, e.relatedTarget);
} else {
throw error;
}
}
_captureRecursion = true;
_captureElem.dispatchEvent(newEv);