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

Commit

Permalink
fix(util): Reverse the order events are triggered
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mbenford committed May 7, 2016
1 parent d6de862 commit 7bc37a6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ tagsInput.factory('tiUtil', function($timeout, $q) {
if (!events[name]) {
events[name] = [];
}
events[name].push(handler);
events[name].unshift(handler);
});
return this;
},
Expand Down
8 changes: 4 additions & 4 deletions test/util.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,17 @@ describe('tiUtil factory', function() {

it('stops the propagation of an event', function() {
// Arrange
var callback1 = jasmine.createSpy().and.returnValue(false),
callback2 = jasmine.createSpy();
var callback1 = jasmine.createSpy(),
callback2 = jasmine.createSpy().and.returnValue(false);

// Act
sut.on('foo', callback1);
sut.on('foo', callback2);
sut.trigger('foo', 'some data');

// Assert
expect(callback1).toHaveBeenCalledWith('some data');
expect(callback2).not.toHaveBeenCalled();
expect(callback2).toHaveBeenCalledWith('some data');
expect(callback1).not.toHaveBeenCalled();
});

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

0 comments on commit 7bc37a6

Please sign in to comment.