Skip to content

Commit

Permalink
Unblocking CSS #273.
Browse files Browse the repository at this point in the history
  • Loading branch information
apetrushin committed Jan 15, 2016
1 parent 4c08223 commit 5f0707a
Showing 1 changed file with 3 additions and 38 deletions.
41 changes: 3 additions & 38 deletions src/curl/plugin/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 5f0707a

Please sign in to comment.