Skip to content

Instantly share code, notes, and snippets.

@ghoullier
Created June 12, 2014 14:16
Show Gist options
  • Save ghoullier/3a9a33008e4c230516a9 to your computer and use it in GitHub Desktop.
Save ghoullier/3a9a33008e4c230516a9 to your computer and use it in GitHub Desktop.
DOM Utilities
;(function(root, name, factory) {
var exports = factory(root);
// AMD
if (typeof define == 'function' && define.amd) {
return define(exports);
}
// CommonJS
if (typeof module !== 'undefined' && module.exports) {
module.exports = exports;
}
// Native Browser
root[name] = exports;
})(this, 'dom', function factory(root) {
var dom = {}
, doc = root.document
, slice = Array.prototype.slice;
function $(selector, context) {
return (context || doc).querySelector(selector);
}
dom.$ = $;
function $$(selector, context) {
return slice.call((context || doc).querySelectorAll(selector));
}
dom.$$ = $$;
return dom;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment