-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathquewery.js
More file actions
35 lines (28 loc) · 811 Bytes
/
quewery.js
File metadata and controls
35 lines (28 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
* Quewery.js (c) 2011 Dan Heberden
*
* Whatever license you want
*/
(function( document, window ) {
function makeArray(arr){
var ret=[],x;
for(x=0;x<arr.length;x++){
ret[x]=arr[x];
}
return ret;
}
var _Quewery = window.Quewery,
_Q = window.Q,
Quewery = window.Q = window.Quewery = function ( selector ) {
return /^#[\w\-]+$/.test( selector )
? [ document.getElementById( selector.slice(1) ) ]
: selector=="body"&&document.body?[document.body]
: !/\W/.test(selector)? makeArray(document.getElementsByTagName(selector))
: document.querySelectorAll( selector );
};
Quewery.noConflict = function( allTheWay ) {
window.Q = _Q;
allTheWay && ( window.Quewery = _Quewery );
return Quewery;
};
})( document, window );