diff --git a/src/jqLite.js b/src/jqLite.js index ef5082ed2233..0cce8f34afd1 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -953,7 +953,12 @@ forEach({ eventData = eventData || []; var event = [{ - preventDefault: noop, + preventDefault: function() { + this.defaultPrevented = true; + }, + isDefaultPrevented: function() { + return this.defaultPrevented === true; + }, stopPropagation: noop }]; diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js index cf880aef0382..01767ce2df07 100644 --- a/test/jqLiteSpec.js +++ b/test/jqLiteSpec.js @@ -1690,6 +1690,20 @@ describe('jqLite', function() { data = pokeSpy.mostRecentCall.args[1]; expect(data.hello).toBe("world"); }); + + it('should mark event as prevented if preventDefault is called', function() { + var element = jqLite('poke'), + pokeSpy = jasmine.createSpy('poke'), + event; + + element.on('click', pokeSpy); + element.triggerHandler('click'); + event = pokeSpy.mostRecentCall.args[0]; + + expect(event.isDefaultPrevented()).toBe(false); + event.preventDefault(); + expect(event.isDefaultPrevented()).toBe(true); + }); });