Skip to content
This repository was archived by the owner on Nov 22, 2021. It is now read-only.

Commit 7bc37a6

Browse files
committed
fix(util): Reverse the order events are triggered
Reverse the order that an event is triggered so the autocomplete directive can work correctly with Angular 1.5, since the order that child directives are compiled has been changed in that version of the framework, due to lazy transclusion (see angular/angular.js#13884 and angular/angular.js@652b83e). Closes #638
1 parent d6de862 commit 7bc37a6

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/util.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ tagsInput.factory('tiUtil', function($timeout, $q) {
111111
if (!events[name]) {
112112
events[name] = [];
113113
}
114-
events[name].push(handler);
114+
events[name].unshift(handler);
115115
});
116116
return this;
117117
},

test/util.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,17 @@ describe('tiUtil factory', function() {
6161

6262
it('stops the propagation of an event', function() {
6363
// Arrange
64-
var callback1 = jasmine.createSpy().and.returnValue(false),
65-
callback2 = jasmine.createSpy();
64+
var callback1 = jasmine.createSpy(),
65+
callback2 = jasmine.createSpy().and.returnValue(false);
6666

6767
// Act
6868
sut.on('foo', callback1);
6969
sut.on('foo', callback2);
7070
sut.trigger('foo', 'some data');
7171

7272
// Assert
73-
expect(callback1).toHaveBeenCalledWith('some data');
74-
expect(callback2).not.toHaveBeenCalled();
73+
expect(callback2).toHaveBeenCalledWith('some data');
74+
expect(callback1).not.toHaveBeenCalled();
7575
});
7676

7777
it('returns the object instance so calls can be chained', function() {

0 commit comments

Comments
 (0)