// ready fn cache
readyStack = [],
- readyBound = false,
+ readyBound = false,
+ readyFired = false,
// Declare a pseudo-private constructor
// Originally proposed by Daniel Brooks
if ( typeof entity === "function" ) {
+
+ // If document ready has already fired
+ if ( document.readyState === "interactive" || document.readyState === "complete" ) {
+
+ entity(document, Popcorn);
+
+ return;
+ }
- readyStack.push( entity );
+ readyStack.push( entity );
+
// This process should happen once per page load
if ( !readyBound ) {
// set readyBound flag
readyBound = true;
-
+
var DOMContentLoaded = function () {
+ readyFired = true;
+
// remove this listener
document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
-
+
// Execute all ready function in the stack
for ( var i = 0; i < readyStack.length; i++ ) {
-
+
readyStack[i].call( document, Popcorn );
-
+
}
// GC readyStack
readyStack = null;
};
-
+
document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false);
}
+
+
return;
}
module("Popcorn");
test("API", function () {
- var expects = 3,
+ var expects = 4,
count = 0;
expect(expects);
plus();
} catch (e) {};
+
+
+ try {
+
+ Popcorn(function() {
+
+ ok(1, "Popcorn calls its function argument");
+ plus();
+
+
+ });
+
+ } catch (e) {};
});