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

Function pollWebKit

lib/web/lazyload/lazyload.js:314–342  ·  view source on GitHub ↗

Begins polling to determine when pending stylesheets have finished loading in WebKit. Polling stops when all pending stylesheets have loaded or after 10 seconds (to prevent stalls). @method pollWebKit @private

()

Source from the content-addressed store, hash-verified

312 @private
313 */
314 function pollWebKit() {
315 var css = pending.css, i;
316
317 if (css) {
318 i = styleSheets.length;
319
320 // Look for a stylesheet matching the pending URL.
321 while (--i >= 0) {
322 if (styleSheets[i].href === css.urls[0]) {
323 finish('css');
324 break;
325 }
326 }
327
328 pollCount += 1;
329
330 if (css) {
331 if (pollCount < 200) {
332 setTimeout(pollWebKit, 50);
333 } else {
334 // We've been polling for 10 seconds and nothing's happened, which may
335 // indicate that the stylesheet has been removed from the document
336 // before it had a chance to load. Stop polling and finish the pending
337 // request to prevent blocking further requests.
338 finish('css');
339 }
340 }
341 }
342 }
343
344 return {
345

Callers 1

loadFunction · 0.85

Calls 1

finishFunction · 0.85

Tested by

no test coverage detected