From 5f0707ac5134670912249255cf3f02f5feffbf0d Mon Sep 17 00:00:00 2001 From: Alexey Petrushin Date: Fri, 15 Jan 2016 12:20:40 +1100 Subject: [PATCH] Unblocking CSS #273. --- src/curl/plugin/css.js | 41 +++-------------------------------------- 1 file changed, 3 insertions(+), 38 deletions(-) diff --git a/src/curl/plugin/css.js b/src/curl/plugin/css.js index 5214717e..a3c8122e 100644 --- a/src/curl/plugin/css.js +++ b/src/curl/plugin/css.js @@ -308,8 +308,8 @@ */ function isLinkReady (link) { var ready, sheet, rules; - // don't bother testing until we've fully initialized the link and doc. - if (!link.href || !isDocumentComplete()) return false; + // don't bother testing until we've fully initialized the link. + if (!link.href) return false; ready = false; try { @@ -416,7 +416,7 @@ // only executes once (link.onload is acting as a flag) if (isFinalized(link)) return; finalize(link); - waitForDocumentComplete(function () { cb(link.sheet); }); + cb(link.sheet); } // always try standard handler loadHandler(link, load); @@ -468,41 +468,6 @@ head.appendChild(link); } - /** - * Keep checking for the document readyState to be "complete" since - * Chrome doesn't apply the styles to the document until that time. - * If we return before readyState == 'complete', Chrome may not have - * applied the styles, yet. - * Chrome only. - * @private - * @param cb - */ - function waitForDocumentComplete (cb) { - // this isn't exactly the same as domReady (when dom can be - // manipulated). it's later (when styles are applied). - // chrome needs this (and opera?) - function complete () { - if (isDocumentComplete()) { - cb(); - } - else { - setTimeout(complete, 10); - } - } - complete(); - } - - /** - * Returns true if the documents' readyState == 'complete' or the - * document doesn't implement readyState. - * Chrome only. - * @private - * @return {Boolean} - */ - function isDocumentComplete () { - return !doc.readyState || doc.readyState == 'complete'; - } - function nameWithExt (name, defaultExt) { return name.lastIndexOf('.') <= name.lastIndexOf('/') ? name + '.' + defaultExt : name;