MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / pollGecko

Function pollGecko

lib/web/lazyload/lazyload.js:278–304  ·  view source on GitHub ↗

Begins polling to determine when the specified stylesheet has finished loading in Gecko. Polling stops when all pending stylesheets have loaded or after 10 seconds (to prevent stalls). Thanks to Zach Leatherman for calling my attention to the @import-based cross-domain technique used here,

(node)

Source from the content-addressed store, hash-verified

276 @private
277 */
278 function pollGecko(node) {
279 var hasRules;
280
281 try {
282 // We don't really need to store this value or ever refer to it again, but
283 // if we don't store it, Closure Compiler assumes the code is useless and
284 // removes it.
285 hasRules = !!node.sheet.cssRules;
286 } catch (ex) {
287 // An exception means the stylesheet is still loading.
288 pollCount += 1;
289
290 if (pollCount < 200) {
291 setTimeout(function () { pollGecko(node); }, 50);
292 } else {
293 // We've been polling for 10 seconds and nothing's happened. Stop
294 // polling and finish the pending requests to avoid blocking further
295 // requests.
296 hasRules && finish('css');
297 }
298
299 return;
300 }
301
302 // If we get here, the stylesheet has loaded.
303 finish('css');
304 }
305
306 /**
307 Begins polling to determine when pending stylesheets have finished loading

Callers 1

loadFunction · 0.85

Calls 1

finishFunction · 0.85

Tested by

no test coverage detected