aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMisko Hevery2013-04-16 09:53:35 -0700
committerMisko Hevery2013-04-22 23:13:26 -0700
commit021bdf3922b6525bd117e59fb4945b30a5a55341 (patch)
tree6de1d0c95cbf433012eb32f39d03ec2da2e0c09e
parentde296f1b52cdf4a50b2095cc4657adb49f75f333 (diff)
downloadangular.js-021bdf3922b6525bd117e59fb4945b30a5a55341.tar.bz2
fix($animator): remove dependency on window.setTimeout.
-rw-r--r--src/Angular.js5
-rw-r--r--src/ng/animator.js8
-rw-r--r--test/ng/animatorSpec.js33
3 files changed, 20 insertions, 26 deletions
diff --git a/src/Angular.js b/src/Angular.js
index a4ef8966..bf64c6c2 100644
--- a/src/Angular.js
+++ b/src/Angular.js
@@ -975,12 +975,13 @@ function bootstrap(element, modules) {
}]);
modules.unshift('ng');
var injector = createInjector(modules);
- injector.invoke(['$rootScope', '$rootElement', '$compile', '$injector',
- function(scope, element, compile, injector) {
+ injector.invoke(['$rootScope', '$rootElement', '$compile', '$injector', '$animator',
+ function(scope, element, compile, injector, animator) {
scope.$apply(function() {
element.data('$injector', injector);
compile(element)(scope);
});
+ animator.enabled(true);
}]
);
return injector;
diff --git a/src/ng/animator.js b/src/ng/animator.js
index 7f0f7b7a..d28ce158 100644
--- a/src/ng/animator.js
+++ b/src/ng/animator.js
@@ -130,14 +130,6 @@ var $AnimatorProvider = function() {
this.$get = ['$animation', '$window', '$sniffer', '$rootElement', '$rootScope',
function($animation, $window, $sniffer, $rootElement, $rootScope) {
$rootElement.data(NG_ANIMATE_CONTROLLER, rootAnimateController);
- var unregister = $rootScope.$watch(function() {
- unregister();
- if (rootAnimateController.running) {
- $window.setTimeout(function() {
- rootAnimateController.running = false;
- }, 0);
- }
- });
/**
* @ngdoc function
diff --git a/test/ng/animatorSpec.js b/test/ng/animatorSpec.js
index 4d549ee3..1b393e91 100644
--- a/test/ng/animatorSpec.js
+++ b/test/ng/animatorSpec.js
@@ -28,20 +28,27 @@ describe("$animator", function() {
});
});
- it("should disable and enable the animations", inject(function($animator, $rootScope, $window) {
- expect($animator.enabled()).toBe(false);
+ it("should disable and enable the animations", function() {
+ var initialState = null;
+ var animator;
- $rootScope.$digest();
- $window.setTimeout.expect(0).process();
+ angular.bootstrap(body, [function() {
+ return function($animator) {
+ animator = $animator;
+ initialState = $animator.enabled();
+ }
+ }]);
- expect($animator.enabled()).toBe(true);
+ expect(initialState).toBe(false);
- expect($animator.enabled(0)).toBe(false);
- expect($animator.enabled()).toBe(false);
+ expect(animator.enabled()).toBe(true);
- expect($animator.enabled(1)).toBe(true);
- expect($animator.enabled()).toBe(true);
- }));
+ expect(animator.enabled(0)).toBe(false);
+ expect(animator.enabled()).toBe(false);
+
+ expect(animator.enabled(1)).toBe(true);
+ expect(animator.enabled()).toBe(true);
+ });
});
@@ -145,9 +152,6 @@ describe("$animator", function() {
ngAnimate : '{enter: \'custom\'}'
});
- $rootScope.$digest(); // re-enable the animations;
- window.setTimeout.expect(0).process();
-
expect(element.contents().length).toBe(0);
animator.enter(child, element);
window.setTimeout.expect(1).process();
@@ -158,9 +162,6 @@ describe("$animator", function() {
ngAnimate : '{leave: \'custom\'}'
});
- $rootScope.$digest(); // re-enable the animations;
- window.setTimeout.expect(0).process();
-
element.append(child);
expect(element.contents().length).toBe(1);
animator.leave(child, element);