UNPKG

basic-mouse-event-polyfill-phantomjs

Version:

This is a simple polyfill to help PhantomJS with handling Mouse Events

29 lines (24 loc) 796 B
(function (window) { try { new MouseEvent('test'); return false; // No need to polyfill } catch (e) { // Need to polyfill - fall through } // Polyfills DOM4 MouseEvent var MouseEvent = function (eventType, params) { params = params || { bubbles: false, cancelable: false, ctrlKey: false, altKey: false, shiftKey: false, metaKey: false }; var mouseEvent = document.createEvent('MouseEvent'); mouseEvent.initMouseEvent(eventType, params.bubbles, params.cancelable, window, 0, 0, 0, 0, 0, params.ctrlKey, params.altKey, params.shiftKey, params.metaKey, 0, null); return mouseEvent; }; MouseEvent.prototype = Event.prototype; window.MouseEvent = MouseEvent; })(window);