'use strict'; function window(target) { if (target.ownerDocument) { return target.ownerDocument.defaultView; } else if (target.defaultView) { return target.defaultView; } else { return target; } } exports.click = function (target, options) { options = Object.assign({bubbles: true}, options); const MouseEvent = window(target).MouseEvent; target.dispatchEvent(new MouseEvent('mousedown', options)); target.dispatchEvent(new MouseEvent('mouseup', options)); target.dispatchEvent(new MouseEvent('click', options)); }; ['mouseup', 'mousedown', 'mouseover', 'mousemove', 'mouseout'].forEach((event) => { exports[event] = function (target, options) { options = Object.assign({bubbles: true}, options); const MouseEvent = window(target).MouseEvent; target.dispatchEvent(new MouseEvent(event, options)); }; }); ['focus', 'blur'].forEach((event) => { exports[event] = function (target, options) { options = Object.assign({bubbles: true}, options); const FocusEvent = window(target).FocusEvent; target.dispatchEvent(new FocusEvent(event, options)); }; });