diff options
| author | Matias Niemelä | 2013-06-17 22:40:01 -0400 | 
|---|---|---|
| committer | Igor Minar | 2013-07-15 09:30:54 -0700 | 
| commit | 031da1f96b3e0074e682e35ac909256c37c91864 (patch) | |
| tree | 105a289325af599d5b9f8d12a6a2b4e5ba672056 | |
| parent | 14626d0bc57cf55e8bde4a329b896308b6c09880 (diff) | |
| download | angular.js-031da1f96b3e0074e682e35ac909256c37c91864.tar.bz2 | |
fix($animator): ensure animations are always disabled for an element that is not attached to the DOM
| -rw-r--r-- | docs/component-spec/annotationsSpec.js | 12 | ||||
| -rw-r--r-- | src/ng/animator.js | 3 | ||||
| -rwxr-xr-x | test/ng/directive/ngIfSpec.js | 16 | ||||
| -rw-r--r-- | test/ng/directive/ngIncludeSpec.js | 16 | ||||
| -rw-r--r-- | test/ng/directive/ngRepeatSpec.js | 16 | ||||
| -rw-r--r-- | test/ng/directive/ngSwitchSpec.js | 16 | ||||
| -rw-r--r-- | test/ngRoute/directive/ngViewSpec.js | 16 | 
7 files changed, 62 insertions, 33 deletions
diff --git a/docs/component-spec/annotationsSpec.js b/docs/component-spec/annotationsSpec.js index b4c8cd9d..29cb9c53 100644 --- a/docs/component-spec/annotationsSpec.js +++ b/docs/component-spec/annotationsSpec.js @@ -91,13 +91,21 @@ describe('Docs Annotations', function() {            }          });        }); -      inject(function($rootScope, $compile, $templateCache) { +      inject(function($rootScope, $compile, $templateCache, $rootElement, $animator) { +        $animator.enabled(true);          url = '/page.html';          $scope = $rootScope.$new();          parent = angular.element('<div class="parent"></div>');          element = angular.element('<div data-url="' + url + '" foldout></div>'); -        body.append(parent); + +        //we're injecting the element to the $rootElement since the changes in +        //$animator only detect and perform animations if the root element has +        //animations enabled. If the element is not apart of the DOM +        //then animations are skipped.          parent.append(element); +        $rootElement.append(parent); +        body.append($rootElement); +          $compile(parent)($scope);          $scope.$apply();        }); diff --git a/src/ng/animator.js b/src/ng/animator.js index 5ad0535f..2a549f12 100644 --- a/src/ng/animator.js +++ b/src/ng/animator.js @@ -290,8 +290,9 @@ var $AnimatorProvider = function() {                if (!parent) {                  parent = after ? after.parent() : element.parent();                } +              var disabledAnimation = { running : true };                if ((!$sniffer.transitions && !polyfillSetup && !polyfillStart) || -                  (parent.inheritedData(NG_ANIMATE_CONTROLLER) || noop).running) { +                  (parent.inheritedData(NG_ANIMATE_CONTROLLER) || disabledAnimation).running) {                  beforeFn(element, parent, after);                  afterFn(element, parent, after);                  return; diff --git a/test/ng/directive/ngIfSpec.js b/test/ng/directive/ngIfSpec.js index 5726e092..0cca57d5 100755 --- a/test/ng/directive/ngIfSpec.js +++ b/test/ng/directive/ngIfSpec.js @@ -77,18 +77,22 @@ describe('ngIf', function () {  describe('ngIf ngAnimate', function () {    var vendorPrefix, window; -  var body, element; +  var body, element, $rootElement;    function html(html) { -    body.html(html); -    element = body.children().eq(0); +    $rootElement.html(html); +    element = $rootElement.children().eq(0);      return element;    } -  beforeEach(function() { +  beforeEach(module(function() {      // we need to run animation on attached elements; -    body = jqLite(document.body); -  }); +    return function(_$rootElement_) { +      $rootElement = _$rootElement_; +      body = jqLite(document.body); +      body.append($rootElement); +    }; +  }));    afterEach(function(){      dealoc(body); diff --git a/test/ng/directive/ngIncludeSpec.js b/test/ng/directive/ngIncludeSpec.js index 2e8d7023..93709431 100644 --- a/test/ng/directive/ngIncludeSpec.js +++ b/test/ng/directive/ngIncludeSpec.js @@ -299,11 +299,11 @@ describe('ngInclude', function() {  describe('ngInclude ngAnimate', function() {    var vendorPrefix, window; -  var body, element; +  var body, element, $rootElement;    function html(html) { -    body.html(html); -    element = body.children().eq(0); +    $rootElement.html(html); +    element = $rootElement.children().eq(0);      return element;    } @@ -312,10 +312,14 @@ describe('ngInclude ngAnimate', function() {      element.css(vendorPrefix + cssProp, cssValue);    } -  beforeEach(function() { +  beforeEach(module(function() {      // we need to run animation on attached elements; -    body = jqLite(document.body); -  }); +    return function(_$rootElement_) { +      $rootElement = _$rootElement_; +      body = jqLite(document.body); +      body.append($rootElement); +    }; +  }));    afterEach(function(){      dealoc(body); diff --git a/test/ng/directive/ngRepeatSpec.js b/test/ng/directive/ngRepeatSpec.js index 492f851d..21ea21e9 100644 --- a/test/ng/directive/ngRepeatSpec.js +++ b/test/ng/directive/ngRepeatSpec.js @@ -708,11 +708,11 @@ describe('ngRepeat', function() {  describe('ngRepeat ngAnimate', function() {    var vendorPrefix, window; -  var body, element; +  var body, element, $rootElement;    function html(html) { -    body.html(html); -    element = body.children().eq(0); +    $rootElement.html(html); +    element = $rootElement.children().eq(0);      return element;    } @@ -721,10 +721,14 @@ describe('ngRepeat ngAnimate', function() {      element.css(vendorPrefix + cssProp, cssValue);    } -  beforeEach(function() { +  beforeEach(module(function() {      // we need to run animation on attached elements; -    body = jqLite(document.body); -  }); +    return function(_$rootElement_) { +      $rootElement = _$rootElement_; +      body = jqLite(document.body); +      body.append($rootElement); +    }; +  }));    afterEach(function(){      dealoc(body); diff --git a/test/ng/directive/ngSwitchSpec.js b/test/ng/directive/ngSwitchSpec.js index 9ccb3b12..ab231ec2 100644 --- a/test/ng/directive/ngSwitchSpec.js +++ b/test/ng/directive/ngSwitchSpec.js @@ -216,18 +216,22 @@ describe('ngSwitch', function() {  describe('ngSwitch ngAnimate', function() {    var vendorPrefix, window; -  var body, element; +  var body, element, $rootElement;    function html(html) { -    body.html(html); -    element = body.children().eq(0); +    $rootElement.html(html); +    element = $rootElement.children().eq(0);      return element;    } -  beforeEach(function() { +  beforeEach(module(function() {      // we need to run animation on attached elements; -    body = jqLite(document.body); -  }); +    return function(_$rootElement_) { +      $rootElement = _$rootElement_; +      body = jqLite(document.body); +      body.append($rootElement); +    }; +  }));    afterEach(function(){      dealoc(body); diff --git a/test/ngRoute/directive/ngViewSpec.js b/test/ngRoute/directive/ngViewSpec.js index 6beb3d27..50531c18 100644 --- a/test/ngRoute/directive/ngViewSpec.js +++ b/test/ngRoute/directive/ngViewSpec.js @@ -511,11 +511,12 @@ describe('ngView', function() {    describe('ngAnimate ', function() {      var window, vendorPrefix; -    var body, element; +    var body, element, $rootElement;      function html(html) { -      body.html(html); -      element = body.children().eq(0); +      $rootElement.html(html); +      body.append($rootElement); +      element = $rootElement.children().eq(0);        return element;      } @@ -524,10 +525,13 @@ describe('ngView', function() {        element.css(vendorPrefix + cssProp, cssValue);      } -    beforeEach(function() { +    beforeEach(module(function() {        // we need to run animation on attached elements; -      body = jqLite(document.body); -    }); +      return function(_$rootElement_) { +        $rootElement = _$rootElement_; +        body = jqLite(document.body); +      }; +    }));      afterEach(function(){        dealoc(body);  | 
