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

Commit 1df3da3

Browse files
committed
fix(bootstrap-prettify): share $animate and $$postDigestQueue with demo 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.
1 parent 27e9340 commit 1df3da3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

docs/components/angular-bootstrap/bootstrap-prettify.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ directive.ngEvalJavascript = ['getEmbeddedTemplate', function(getEmbeddedTemplat
192192

193193

194194
directive.ngEmbedApp = ['$templateCache', '$browser', '$rootScope', '$location', '$sniffer', '$animate',
195-
function($templateCache, $browser, docsRootScope, $location, $sniffer, $animate) {
195+
function($templateCache, $browser, docsRootScope, $location, $sniffer, $animate) {
196196
return {
197197
terminal: true,
198198
link: function(scope, element, attrs) {
@@ -205,6 +205,7 @@ directive.ngEmbedApp = ['$templateCache', '$browser', '$rootScope', '$location',
205205
$provide.value('$anchorScroll', angular.noop);
206206
$provide.value('$browser', $browser);
207207
$provide.value('$sniffer', $sniffer);
208+
$provide.value('$animate', $animate);
208209
$provide.provider('$location', function() {
209210
this.$get = ['$rootScope', function($rootScope) {
210211
docsRootScope.$on('$locationChangeSuccess', function(event, oldUrl, newUrl) {
@@ -227,6 +228,11 @@ directive.ngEmbedApp = ['$templateCache', '$browser', '$rootScope', '$location',
227228
}]);
228229
$provide.decorator('$rootScope', ['$delegate', function($delegate) {
229230
embedRootScope = $delegate;
231+
232+
// Since we are teleporting the $animate service, which relies on the $$postDigestQueue
233+
// we need the embedded scope to use the same $$postDigestQueue as the outer scope
234+
embedRootScope.$$postDigestQueue = docsRootScope.$$postDigestQueue;
235+
230236
deregisterEmbedRootScope = docsRootScope.$watch(function embedRootScopeDigestWatch() {
231237
embedRootScope.$digest();
232238
});

0 commit comments

Comments
 (0)