Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve reliability of readyState on IE (possible fix for #154, #195) #196

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 17 additions & 5 deletions yepnope.js
Expand Up @@ -69,7 +69,7 @@ var docElement = doc.documentElement,
/* Loader helper functions */
function isFileReady ( readyState ) {
// Check to see if any of the ways a file can be ready are available as properties on the file's element
return ( ! readyState || readyState == "loaded" || readyState == "complete" || readyState == "uninitialized" );
return ( ! readyState || readyState == "loaded" || readyState == "complete" );
}


Expand All @@ -95,7 +95,13 @@ var docElement = doc.documentElement,
script.onreadystatechange = script.onload = function () {

if ( ! done && isFileReady( script.readyState ) ) {


// Inject script into to document (if NOT using onload)
if(!err && script.readyState){
readFirstScript();
firstScript.parentNode.insertBefore( script, firstScript );
}

// Set done to prevent this function from being called twice.
done = 1;
cb();
Expand All @@ -114,11 +120,17 @@ var docElement = doc.documentElement,
}
}, timeout );

// Inject script into to document
// Inject script into to document (if using onload)
// or immediately callback if we know there
// was previously a timeout error
readFirstScript();
err ? script.onload() : firstScript.parentNode.insertBefore( script, firstScript );
if(!err){
if(!script.readyState){
readFirstScript();
firstScript.parentNode.insertBefore( script, firstScript );
}
}else{
script.onload()
}
}

// Takes a preloaded css obj (changes in different browsers) and injects it into the head
Expand Down