Created
December 22, 2011 20:20
-
-
Save SlexAxton/1511705 to your computer and use it in GitHub Desktop.
jQuery constructor recreation attempt
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
(function (window, undefined) { | |
var MRTN = (function() { | |
// The main FeedTheWebDev function | |
var MRTN = function(element) { | |
return new MRTN.fn.init(element, rootDoc); | |
}, | |
// Ref to root document | |
rootDoc; | |
MRTN.fn = MRTN.prototype = { | |
constructor: MRTN, | |
init: function(element, rootDoc) { | |
// Handle empty 'constructor' | |
if (!element) { | |
return this; | |
} | |
// It's a single element | |
if (element.nodeType) { | |
this.element = this[0] = element; | |
this.length = 1; | |
return this; | |
} | |
}, | |
splice : function () {}, | |
length: 0 | |
}; | |
MRTN.fn.init.prototype = MRTN.prototype; | |
rootDoc = MRTN(document); | |
return MRTN; | |
})(); | |
window.MRTN = MRTN; | |
}(window)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment