X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fcore.js;h=582e53e7c62e1d6b1da74f2d550985bbdc79327a;hb=9ea8017f86c48ab624fbdc0e55a79110d9c61a9f;hp=27a57283e98f44eb799cde23dfe2c2ac108a3974;hpb=ccf055033ab165c677590b42fa0ca7e0a29e9fb7;p=jquery.git diff --git a/src/core.js b/src/core.js index 27a5728..582e53e 100644 --- a/src/core.js +++ b/src/core.js @@ -14,10 +14,8 @@ if ( window.jQuery ) var _jQuery = window.jQuery; var jQuery = window.jQuery = function( selector, context ) { - // If the context is a namespace object, return a new object - return this instanceof jQuery ? - this.init( selector, context ) : - new jQuery( selector, context ); + // The jQuery object is actually just the init constructor 'enhanced' + return new jQuery.prototype.init( selector, context ); }; // Map over the $ in case of overwrite @@ -496,16 +494,9 @@ jQuery.fn = jQuery.prototype = { this.cloneNode( true ) : this; + // execute all scripts after the elements have been injected if ( jQuery.nodeName( elem, "script" ) ) { - - // If scripts are waiting to be executed, wait on this script as well - if ( scripts.length ) - scripts = scripts.add( elem ); - - // If nothing is waiting to be executed, run immediately - else - evalScript( 0, elem ); - + scripts = scripts.add( elem ); } else { // Remove any inner scripts for later evaluation if ( elem.nodeType == 1 ) @@ -521,6 +512,9 @@ jQuery.fn = jQuery.prototype = { } }; +// Give the init function the jQuery prototype for later instantiation +jQuery.prototype.init.prototype = jQuery.prototype; + function evalScript( i, elem ) { if ( elem.src ) jQuery.ajax({