forked from finom/tsimmes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bala.umd.js
40 lines (34 loc) · 1.32 KB
/
bala.umd.js
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
36
37
38
39
40
(function(root, $) {
$ = ((document, s_querySelectorAll, fn, $) => (
($ = (s, context, bala) => (
(bala = Object.create(fn)),
s && bala.push( // if s is truly then push the following
...(s.dispatchEvent // if arg is node or window,
? [s] // then pass [s]
: typeof s == 'string' // else if arg is a string
? /</.test(s) // if the string contains "<" (if HTML code is passed)
// then parse it and return node.children
// use 'querySelectorAll' (HTMLUnknownElement) if content is not presented
? ((context = document.createElement(context || s_querySelectorAll)).innerHTML = s
, context.children)
: context // else if context is truly
? ((context = $(context)[0]) // if context element is found
? context[s_querySelectorAll](s) // then select element from context
: bala) // else pass [] (context isn't found)
: document[s_querySelectorAll](s) // else select elements globally
: s.length ? s : fn)), // else guessing that s variable is array-like Object
bala
)),
($.fn = fn),
($.one = (s, context) => $(s, context)[0]),
$
))(document, 'querySelectorAll', []);
;
if (typeof define == 'function' && define.amd) {
define([], () => $);
} else if (typeof module == 'object' && module.exports) {
module.exports = $;
} else {
root.$ = $;
}
})(this);