aboutsummaryrefslogtreecommitdiffstats
path: root/test/jqLiteSpec.js
diff options
context:
space:
mode:
authorJulie2013-04-15 15:52:56 -0700
committerIgor Minar2013-05-16 16:15:31 -0700
commit0401a7f598ef9a36ffe1f217e1a98961046fa551 (patch)
treed727f4276e1993caa99e338f72385d909d5c07e0 /test/jqLiteSpec.js
parent6798fec4390a72b7943a49505f8a245b6016c84b (diff)
downloadangular.js-0401a7f598ef9a36ffe1f217e1a98961046fa551.tar.bz2
fix(jqLite): pass a dummy event into triggerHandler
Previously, anchor elements could not be used with triggerHandler because triggerHandler passes null as the event, and any anchor element with an empty href automatically calls event.preventDefault(). Instead, pass a dummy event when using triggerHandler, similar to what full jQuery does. Modified from PR #2379.
Diffstat (limited to 'test/jqLiteSpec.js')
-rw-r--r--test/jqLiteSpec.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js
index 089ae78c..1ebe6ad4 100644
--- a/test/jqLiteSpec.js
+++ b/test/jqLiteSpec.js
@@ -792,7 +792,7 @@ describe('jqLite', function() {
if (msie < 9){
var evnt = document.createEventObject();
evnt.srcElement = element;
- evnt.relatedTarget = relatedTarget;
+ evnt.relatedTarget = relatedTarget;
element.fireEvent('on' + type, evnt);
return;
};
@@ -1153,6 +1153,21 @@ describe('jqLite', function() {
expect(clickSpy1).toHaveBeenCalledOnce();
expect(clickSpy2).toHaveBeenCalledOnce();
});
+
+ it('should pass in a dummy event', function() {
+ // we need the event to have at least preventDefault because angular will call it on
+ // all anchors with no href automatically
+
+ var element = jqLite('<a>poke</a>'),
+ pokeSpy = jasmine.createSpy('poke'),
+ event;
+
+ element.bind('click', pokeSpy);
+
+ element.triggerHandler('click');
+ event = pokeSpy.mostRecentCall.args[0];
+ expect(event.preventDefault).toBeDefined();
+ });
});