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