(rootElement, skipRootElement)
| 97 | } |
| 98 | |
| 99 | function processAllImpl(rootElement, skipRootElement) { |
| 100 | return new Promise(function processAllImpl2(complete, error) { |
| 101 | _WriteProfilerMark("WinJS.UI:processAll,StartTM"); |
| 102 | rootElement = rootElement || _Global.document.body; |
| 103 | var pending = 0; |
| 104 | var selector = "[data-win-control]"; |
| 105 | var allElements = rootElement.querySelectorAll(selector); |
| 106 | var elements = []; |
| 107 | if (!skipRootElement && getControlHandler(rootElement)) { |
| 108 | elements.push(rootElement); |
| 109 | } |
| 110 | for (var i = 0, len = allElements.length; i < len; i++) { |
| 111 | elements.push(allElements[i]); |
| 112 | } |
| 113 | |
| 114 | // bail early if there is nothing to process |
| 115 | // |
| 116 | if (elements.length === 0) { |
| 117 | _WriteProfilerMark("WinJS.UI:processAll,StopTM"); |
| 118 | complete(rootElement); |
| 119 | return; |
| 120 | } |
| 121 | |
| 122 | var checkAllComplete = function () { |
| 123 | pending = pending - 1; |
| 124 | if (pending < 0) { |
| 125 | _WriteProfilerMark("WinJS.UI:processAll,StopTM"); |
| 126 | complete(rootElement); |
| 127 | } |
| 128 | }; |
| 129 | |
| 130 | // First go through and determine which elements to activate |
| 131 | // |
| 132 | var controls = new Array(elements.length); |
| 133 | for (var i = 0, len = elements.length; i < len; i++) { |
| 134 | var element = elements[i]; |
| 135 | var control; |
| 136 | var instance = element.winControl; |
| 137 | if (instance) { |
| 138 | control = instance.constructor; |
| 139 | // already activated, don't need to add to controls array |
| 140 | } else { |
| 141 | controls[i] = control = getControlHandler(element); |
| 142 | } |
| 143 | if (control && control.isDeclarativeControlContainer) { |
| 144 | i += element.querySelectorAll(selector).length; |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | // Now go through and activate those |
| 149 | // |
| 150 | _WriteProfilerMark("WinJS.UI:processAllActivateControls,StartTM"); |
| 151 | for (var i = 0, len = elements.length; i < len; i++) { |
| 152 | var ctl = controls[i]; |
| 153 | var element = elements[i]; |
| 154 | if (ctl && !element.winControl) { |
| 155 | pending++; |
| 156 | activate(element, ctl).then(checkAllComplete, function (e) { |
no test coverage detected