Skip to content

Instantly share code, notes, and snippets.

@MikeDigitize
Last active July 25, 2016 06:51
Show Gist options
  • Save MikeDigitize/1674ff4274aa58cb49b1db97a908eb11 to your computer and use it in GitHub Desktop.
Save MikeDigitize/1674ff4274aa58cb49b1db97a908eb11 to your computer and use it in GitHub Desktop.
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