Created
June 27, 2012 14:57
-
-
Save kswlee/3004628 to your computer and use it in GitHub Desktop.
Simplified jQuery Core
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var jQuery = (function() { | |
| // Define a local copy of jQuery | |
| var jQuery = function( selector, context ) { | |
| // The jQuery object is actually just the init constructor 'enhanced' | |
| return new jQuery.fn.init( selector, context ); | |
| }, | |
| // A central reference to the root jQuery(document) | |
| rootjQuery; | |
| jQuery.fn = jQuery.prototype = { | |
| constructor: jQuery, | |
| init: function( selector, context, rootjQuery ) { | |
| this.context = this[0] = document.body; | |
| this.length = 1; | |
| return this; | |
| }, | |
| // The default length of a jQuery object is 0, and make it act like [] | |
| length: 0, | |
| splice: [].splice | |
| }; | |
| // Give the init function the jQuery prototype for later instantiation | |
| jQuery.fn.init.prototype = jQuery.fn; | |
| rootjQuery = jQuery(document); | |
| return jQuery; | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment