Skip to content

Instantly share code, notes, and snippets.

@CraigCav
Last active December 17, 2015 23:19
Show Gist options
  • Save CraigCav/5688709 to your computer and use it in GitHub Desktop.
Save CraigCav/5688709 to your computer and use it in GitHub Desktop.
(function (exports) {
"use strict";
function tQuery(selector, context) {
var isNew = !(this == window || typeof this === "undefined");
if(!isNew) return new tQuery(selector, context);
var target = context || document;
var elementsList = target.querySelectorAll(selector);
Array.prototype.forEach.call(elementsList, function(element, idx) {
this[idx] = element
}.bind(this));
this.length = elementsList.length;
}
tQuery.prototype.forEach = function(callback) {
for (var i = 0; i < this.length; i++) {
callback.call(this[i], this[i], i);
};
};
exports.$$ = exports.tQuery = tQuery;
})(window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment