Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix(bootstrap-prettify): share $animate and $$postDigestQueue with de…
Browse files Browse the repository at this point in the history
…mo apps

Although demo apps run in an isolated environment, we need to be able to tell them to disable
animations when we are running end-to-end tests.  By sharing the same instance of $animate
between the two environments we can disable animation across the board.

The $animate service uses the $$postDigestQueue to run animations.  The outer $animate
service uses the outer $$postDigestQueue and to queue up these animations.  This means that
when we run a digest inside the embedded scope, the animations are never performed - they
just sit in the outer scope's queue and are only run when a digest is run on the outer scope.
By sharing this queue across the two scopes the animations are performed correctly.
  • Loading branch information
IgorMinar committed Nov 8, 2013
1 parent 27e9340 commit 1df3da3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docs/components/angular-bootstrap/bootstrap-prettify.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ directive.ngEvalJavascript = ['getEmbeddedTemplate', function(getEmbeddedTemplat


directive.ngEmbedApp = ['$templateCache', '$browser', '$rootScope', '$location', '$sniffer', '$animate',
function($templateCache, $browser, docsRootScope, $location, $sniffer, $animate) {
function($templateCache, $browser, docsRootScope, $location, $sniffer, $animate) {
return {
terminal: true,
link: function(scope, element, attrs) {
Expand All @@ -205,6 +205,7 @@ directive.ngEmbedApp = ['$templateCache', '$browser', '$rootScope', '$location',
$provide.value('$anchorScroll', angular.noop);
$provide.value('$browser', $browser);
$provide.value('$sniffer', $sniffer);
$provide.value('$animate', $animate);
$provide.provider('$location', function() {
this.$get = ['$rootScope', function($rootScope) {
docsRootScope.$on('$locationChangeSuccess', function(event, oldUrl, newUrl) {
Expand All @@ -227,6 +228,11 @@ directive.ngEmbedApp = ['$templateCache', '$browser', '$rootScope', '$location',
}]);
$provide.decorator('$rootScope', ['$delegate', function($delegate) {
embedRootScope = $delegate;

// Since we are teleporting the $animate service, which relies on the $$postDigestQueue
// we need the embedded scope to use the same $$postDigestQueue as the outer scope
embedRootScope.$$postDigestQueue = docsRootScope.$$postDigestQueue;

deregisterEmbedRootScope = docsRootScope.$watch(function embedRootScopeDigestWatch() {
embedRootScope.$digest();
});
Expand Down

0 comments on commit 1df3da3

Please sign in to comment.