|
1 | 1 | (function() { |
2 | 2 | 'use strict'; |
3 | 3 | var regModules = ['ng'], |
4 | | - initModules = [], |
5 | 4 | regInvokes = {}, |
6 | 5 | regConfigs = [], |
7 | 6 | justLoaded = [], |
8 | 7 | runBlocks = {}, |
9 | 8 | ocLazyLoad = angular.module('oc.lazyLoad', ['ng']), |
10 | | - broadcast = angular.noop; |
| 9 | + broadcast = angular.noop, |
| 10 | + modulesToLoad = []; |
11 | 11 |
|
12 | 12 | ocLazyLoad.provider('$ocLazyLoad', ['$controllerProvider', '$provide', '$compileProvider', '$filterProvider', '$injector', '$animateProvider', |
13 | 13 | function($controllerProvider, $provide, $compileProvider, $filterProvider, $injector, $animateProvider) { |
|
904 | 904 | * @param element |
905 | 905 | */ |
906 | 906 | function init(element) { |
907 | | - if(initModules.length === 0) { |
| 907 | + if(modulesToLoad.length === 0) { |
908 | 908 | var elements = [element], |
909 | 909 | names = ['ng:app', 'ng-app', 'x-ng-app', 'data-ng-app'], |
910 | 910 | NG_APP_CLASS_REGEXP = /\sng[:\-]app(:\s*([\w\d_]+);?)?\s/, |
|
924 | 924 | }); |
925 | 925 |
|
926 | 926 | angular.forEach(elements, function(elm) { |
927 | | - if(initModules.length === 0) { |
| 927 | + if(modulesToLoad.length === 0) { |
928 | 928 | var className = ' ' + element.className + ' '; |
929 | 929 | var match = NG_APP_CLASS_REGEXP.exec(className); |
930 | 930 | if(match) { |
931 | | - initModules.push((match[2] || '').replace(/\s+/g, ',')); |
| 931 | + modulesToLoad.push((match[2] || '').replace(/\s+/g, ',')); |
932 | 932 | } else { |
933 | 933 | angular.forEach(elm.attributes, function(attr) { |
934 | | - if(initModules.length === 0 && names[attr.name]) { |
935 | | - initModules.push(attr.value); |
| 934 | + if(modulesToLoad.length === 0 && names[attr.name]) { |
| 935 | + modulesToLoad.push(attr.value); |
936 | 936 | } |
937 | 937 | }); |
938 | 938 | } |
|
958 | 958 | } |
959 | 959 | }; |
960 | 960 |
|
961 | | - angular.forEach(initModules, function(moduleName) { |
| 961 | + angular.forEach(modulesToLoad, function(moduleName) { |
962 | 962 | addReg(moduleName); |
963 | 963 | }); |
964 | 964 |
|
965 | | - initModules = []; // reset for next bootstrap |
966 | 965 | angular.module = ngModuleFct; // restore angular.module |
| 966 | + modulesToLoad = []; // reset for next bootstrap |
967 | 967 | } |
968 | 968 |
|
969 | 969 | var bootstrapFct = angular.bootstrap; |
970 | 970 | angular.bootstrap = function(element, modules, config) { |
971 | | - initModules = modules.slice(); // make a clean copy |
| 971 | + modulesToLoad = modules.slice(); // make a clean copy |
972 | 972 | return bootstrapFct(element, modules, config); |
973 | 973 | }; |
974 | 974 |
|
975 | 975 | var addToInit = function addToInit(name) { |
976 | | - if(angular.isString(name) && initModules.indexOf(name) === -1) { |
977 | | - initModules.push(name); |
| 976 | + if(angular.isString(name) && modulesToLoad.indexOf(name) === -1) { |
| 977 | + modulesToLoad.push(name); |
978 | 978 | } |
979 | 979 | }; |
980 | 980 |
|
|
0 commit comments