Last active
July 25, 2016 06:51
-
-
Save MikeDigitize/1674ff4274aa58cb49b1db97a908eb11 to your computer and use it in GitHub Desktop.
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() { | |
function jQuery(selector, context = document) { | |
return new jQuery.fn.init(selector, context); | |
} | |
jQuery.fn = jQuery.prototype ; | |
jQuery.fn.css = function(prop, value) { | |
this.pushStack.forEach(el => el.style[prop] = value); | |
return this; | |
} | |
jQuery.fn.text = function(text) { | |
this.pushStack.forEach(el => el.textContent = text); | |
return this; | |
} | |
var Init = function(selector, context) { | |
context = typeof context === 'string' ? document.querySelector(context) : context; | |
this.pushStack = context.querySelectorAll(selector); | |
this.pushStack.forEach = [].forEach; | |
this.length = this.pushStack.length; | |
this.selector = selector; | |
this.context = context; | |
} | |
jQuery.fn.init = Init; | |
jQuery.fn.init.prototype = jQuery.fn; | |
return (window.jQuery = window.$ = jQuery); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment