diff --git a/src/ngAnimate/animateQueue.js b/src/ngAnimate/animateQueue.js index d69eae33dee7..bf92b55544e6 100644 --- a/src/ngAnimate/animateQueue.js +++ b/src/ngAnimate/animateQueue.js @@ -631,8 +631,9 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) { if (!rootElementDetected) { parentHost = parentElement.data(NG_ANIMATE_PIN_DATA); if (parentHost) { + // The pin target element becomes the parent element parentElement = parentHost; - rootElementDetected = true; + rootElementDetected = isMatchingElement(parentElement, $rootElement); } } } diff --git a/test/ngAnimate/animateSpec.js b/test/ngAnimate/animateSpec.js index d281d0abfe0f..770d4907c694 100644 --- a/test/ngAnimate/animateSpec.js +++ b/test/ngAnimate/animateSpec.js @@ -1543,6 +1543,49 @@ describe("animations", function() { }); }); + they('should not animate an element when the pinned element (which is the $prop element), is pinned to an element that is not a child of the $rootElement', + ['same', 'parent', 'grandparent'], + function(elementRelation) { + inject(function($animate, $compile, $document, $rootElement, $rootScope) { + + var pinElement, animateElement, pinTargetElement = jqLite('
'); + + var innerParent = jqLite(''); + jqLite($document[0].body).append(innerParent); + innerParent.append($rootElement); + + switch (elementRelation) { + case 'same': + pinElement = jqLite(''); + break; + case 'parent': + pinElement = jqLite('