Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Event properties is not preserved across different listeners calls in IE, so we have to make all checks in the same listener. Also: control case added. Note: previously here used to be different implementation that was also reliable, as it relied on return value of https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/dispatchEvent ``` function dispatchClick(el) { // return: cancelled if (document.createEvent) { var e = document.createEvent('MouseEvents'); e.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); return el.dispatchEvent(e); } else if (el.fireEvent) { // IE<11 return el.fireEvent('onclick'); } } it('prevents the default action of event', function () { expect(dispatchClick(el)).to.be.ok(); // control case L.DomEvent.on(el, 'click', L.DomEvent.preventDefault); expect(dispatchClick(el)).to.not.be.ok(); }); ```
- Loading branch information