Created
June 12, 2014 14:16
-
-
Save ghoullier/3a9a33008e4c230516a9 to your computer and use it in GitHub Desktop.
DOM Utilities
This file contains 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(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