mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
fix($animate): ensure enable/disable animations work when the document node is used
Closes #4669
This commit is contained in:
parent
7484830744
commit
6818542c69
2 changed files with 45 additions and 2 deletions
|
|
@ -705,13 +705,16 @@ angular.module('ngAnimate', ['ng'])
|
|||
//the element did not reach the root element which means that it
|
||||
//is not apart of the DOM. Therefore there is no reason to do
|
||||
//any animations on it
|
||||
if(parent.length === 0 || parent[0] == $document[0]) return true;
|
||||
if(parent.length === 0) return true;
|
||||
|
||||
var state = parent.data(NG_ANIMATE_STATE);
|
||||
var isRoot = parent[0] == $rootElement[0];
|
||||
var state = isRoot ? rootAnimateState : parent.data(NG_ANIMATE_STATE);
|
||||
if(state && (state.disabled != null || state.running != null)) {
|
||||
validState = state;
|
||||
break;
|
||||
}
|
||||
|
||||
if(isRoot) return true;
|
||||
}
|
||||
while(parent = parent.parent());
|
||||
|
||||
|
|
|
|||
|
|
@ -120,6 +120,46 @@ describe("ngAnimate", function() {
|
|||
expect(count).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
it('should check enable/disable animations up until the $rootElement element', function() {
|
||||
var rootElm = jqLite('<div></div>');
|
||||
|
||||
var captured = false;
|
||||
module(function($provide, $animateProvider) {
|
||||
$provide.value('$rootElement', rootElm);
|
||||
$animateProvider.register('.ani', function() {
|
||||
return {
|
||||
addClass : function(element, className, done) {
|
||||
captured = true;
|
||||
done();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
inject(function($animate, $rootElement, $rootScope, $compile, $timeout) {
|
||||
var initialState;
|
||||
angular.bootstrap(rootElm, ['ngAnimate']);
|
||||
|
||||
$animate.enabled(true);
|
||||
|
||||
var element = $compile('<div class="ani"></div>')($rootScope);
|
||||
rootElm.append(element);
|
||||
|
||||
expect(captured).toBe(false);
|
||||
$animate.addClass(element, 'red');
|
||||
expect(captured).toBe(true);
|
||||
|
||||
captured = false;
|
||||
$animate.enabled(false);
|
||||
|
||||
$animate.addClass(element, 'blue');
|
||||
expect(captured).toBe(false);
|
||||
|
||||
//clean up the mess
|
||||
$animate.enabled(false, rootElm);
|
||||
dealoc(rootElm);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("with polyfill", function() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue