From 6d65fc3dd7898b7fffdd75dd7e171a5e71201fbf Mon Sep 17 00:00:00 2001 From: Martin Staffa Date: Wed, 2 Dec 2015 16:39:14 +0100 Subject: [PATCH] fix($animate): make .pin() work with nested elements Related #12617 --- src/ngAnimate/animateQueue.js | 1 + test/ngAnimate/animateSpec.js | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/ngAnimate/animateQueue.js b/src/ngAnimate/animateQueue.js index 0d22adc35c40..c9af6632e647 100644 --- a/src/ngAnimate/animateQueue.js +++ b/src/ngAnimate/animateQueue.js @@ -586,6 +586,7 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) { parentHost = parentElement.data(NG_ANIMATE_PIN_DATA); if (parentHost) { parentElement = parentHost; + rootElementDetected = true; } } } diff --git a/test/ngAnimate/animateSpec.js b/test/ngAnimate/animateSpec.js index 1cb8f197c308..6efa19764aaa 100644 --- a/test/ngAnimate/animateSpec.js +++ b/test/ngAnimate/animateSpec.js @@ -1432,20 +1432,22 @@ describe("animations", function() { jqLite($document[0].body).append(innerParent); innerParent.append($rootElement); - var element = jqLite('
'); - jqLite($document[0].body).append(element); + var pinElement = jqLite('

'); + jqLite($document[0].body).append(pinElement); - $animate.addClass(element, 'red'); + var animateElement = pinElement.find('p'); + + $animate.addClass(animateElement, 'red'); $rootScope.$digest(); expect(capturedAnimation).toBeFalsy(); - $animate.pin(element, $rootElement); + $animate.pin(pinElement, $rootElement); - $animate.addClass(element, 'blue'); + $animate.addClass(animateElement, 'blue'); $rootScope.$digest(); expect(capturedAnimation).toBeTruthy(); - dealoc(element); + dealoc(pinElement); })); it('should adhere to the disabled state of the hosted parent when an element is pinned',