Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 021bdf3

Browse files
committed
fix($animator): remove dependency on window.setTimeout.
1 parent de296f1 commit 021bdf3

File tree

3 files changed

+20
-26
lines changed

3 files changed

+20
-26
lines changed

src/Angular.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -975,12 +975,13 @@ function bootstrap(element, modules) {
975975
}]);
976976
modules.unshift('ng');
977977
var injector = createInjector(modules);
978-
injector.invoke(['$rootScope', '$rootElement', '$compile', '$injector',
979-
function(scope, element, compile, injector) {
978+
injector.invoke(['$rootScope', '$rootElement', '$compile', '$injector', '$animator',
979+
function(scope, element, compile, injector, animator) {
980980
scope.$apply(function() {
981981
element.data('$injector', injector);
982982
compile(element)(scope);
983983
});
984+
animator.enabled(true);
984985
}]
985986
);
986987
return injector;

src/ng/animator.js

-8
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,6 @@ var $AnimatorProvider = function() {
130130
this.$get = ['$animation', '$window', '$sniffer', '$rootElement', '$rootScope',
131131
function($animation, $window, $sniffer, $rootElement, $rootScope) {
132132
$rootElement.data(NG_ANIMATE_CONTROLLER, rootAnimateController);
133-
var unregister = $rootScope.$watch(function() {
134-
unregister();
135-
if (rootAnimateController.running) {
136-
$window.setTimeout(function() {
137-
rootAnimateController.running = false;
138-
}, 0);
139-
}
140-
});
141133

142134
/**
143135
* @ngdoc function

test/ng/animatorSpec.js

+17-16
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,27 @@ describe("$animator", function() {
2828
});
2929
});
3030

31-
it("should disable and enable the animations", inject(function($animator, $rootScope, $window) {
32-
expect($animator.enabled()).toBe(false);
31+
it("should disable and enable the animations", function() {
32+
var initialState = null;
33+
var animator;
3334

34-
$rootScope.$digest();
35-
$window.setTimeout.expect(0).process();
35+
angular.bootstrap(body, [function() {
36+
return function($animator) {
37+
animator = $animator;
38+
initialState = $animator.enabled();
39+
}
40+
}]);
3641

37-
expect($animator.enabled()).toBe(true);
42+
expect(initialState).toBe(false);
3843

39-
expect($animator.enabled(0)).toBe(false);
40-
expect($animator.enabled()).toBe(false);
44+
expect(animator.enabled()).toBe(true);
4145

42-
expect($animator.enabled(1)).toBe(true);
43-
expect($animator.enabled()).toBe(true);
44-
}));
46+
expect(animator.enabled(0)).toBe(false);
47+
expect(animator.enabled()).toBe(false);
48+
49+
expect(animator.enabled(1)).toBe(true);
50+
expect(animator.enabled()).toBe(true);
51+
});
4552

4653
});
4754

@@ -145,9 +152,6 @@ describe("$animator", function() {
145152
ngAnimate : '{enter: \'custom\'}'
146153
});
147154

148-
$rootScope.$digest(); // re-enable the animations;
149-
window.setTimeout.expect(0).process();
150-
151155
expect(element.contents().length).toBe(0);
152156
animator.enter(child, element);
153157
window.setTimeout.expect(1).process();
@@ -158,9 +162,6 @@ describe("$animator", function() {
158162
ngAnimate : '{leave: \'custom\'}'
159163
});
160164

161-
$rootScope.$digest(); // re-enable the animations;
162-
window.setTimeout.expect(0).process();
163-
164165
element.append(child);
165166
expect(element.contents().length).toBe(1);
166167
animator.leave(child, element);

0 commit comments

Comments
 (0)