From 641f9925248fcebcb076171fc13df0b9dc963188 Mon Sep 17 00:00:00 2001 From: chrismilleruk Date: Wed, 20 Mar 2013 09:17:03 +0000 Subject: [PATCH] Set up an event listener on {appFrame}.document.body if the angular-scenario.angularInit() fails to connect. Make sure the manual bootstrap fires the above event. --- app/lib/angular/angular.js | 11 +++++++++-- test/lib/angular/angular-scenario.js | 18 +++++++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/app/lib/angular/angular.js b/app/lib/angular/angular.js index fdc5100f0a..e9e397b331 100644 --- a/app/lib/angular/angular.js +++ b/app/lib/angular/angular.js @@ -893,8 +893,9 @@ function encodeUriQuery(val, pctEncodeSpaces) { * */ -function angularInit(element, bootstrap) { +function angularInit(element, callback, errCallback) { var elements = [element], + document = element.ownerDocument || element, appElement, module, names = ['ng:app', 'ng-app', 'x-ng-app', 'data-ng-app'], @@ -933,7 +934,9 @@ function angularInit(element, bootstrap) { } }); if (appElement) { - bootstrap(appElement, module ? [module] : []); + callback(appElement, module ? [module] : []); + } else if (callback !== bootstrap && errCallback) { + errCallback(); } } @@ -968,6 +971,10 @@ function bootstrap(element, modules) { var cls = ': ' + modules[2] + ';'; cls = 'ng-app' + (cls||''); element.addClass(cls); + + // ..when it has already run. + var document = element[0].ownerDocument || element[0]; + JQLite(document.body).triggerHandler('ngBootstrap'); }); }] ); diff --git a/test/lib/angular/angular-scenario.js b/test/lib/angular/angular-scenario.js index 2a0a3adaad..974a9dbd0a 100644 --- a/test/lib/angular/angular-scenario.js +++ b/test/lib/angular/angular-scenario.js @@ -10298,8 +10298,9 @@ function encodeUriQuery(val, pctEncodeSpaces) { * */ -function angularInit(element, bootstrap) { +function angularInit(element, callback, errCallback) { var elements = [element], + document = element.ownerDocument || element, appElement, module, names = ['ng:app', 'ng-app', 'x-ng-app', 'data-ng-app'], @@ -10338,7 +10339,9 @@ function angularInit(element, bootstrap) { } }); if (appElement) { - bootstrap(appElement, module ? [module] : []); + callback(appElement, module ? [module] : []); + } else if (callback !== bootstrap && errCallback) { + errCallback(); } } @@ -10373,6 +10376,10 @@ function bootstrap(element, modules) { var cls = ': ' + modules[2] + ';'; cls = 'ng-app' + (cls||''); element.addClass(cls); + + // ..when it has already run. + var document = element[0].ownerDocument || element[0]; + JQLite(document.body).triggerHandler('ngBootstrap'); }); }] ); @@ -24637,7 +24644,7 @@ angular.scenario.Application.prototype.executeAction = function(action) { if (!$window.angular) { return action.call(this, $window, _jQuery($window.document)); } - angularInit($window.document, function(element) { + var scenarioBootstrap = function(element) { var $injector = $window.angular.element(element).injector(); var $element = _jQuery(element); @@ -24650,6 +24657,11 @@ angular.scenario.Application.prototype.executeAction = function(action) { action.call(self, $window, $element); }); }); + }; + angularInit($window.document, scenarioBootstrap, function(){ + $window.angular.element($window.document.body).bind('ngBootstrap', function(){ + angularInit($window.document, scenarioBootstrap); + }); }); };