forked from WebReflection/hyperHTML
-
Notifications
You must be signed in to change notification settings - Fork 0
/
no.js
38 lines (38 loc) · 1.02 KB
/
no.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
(function (hyperHTML) {
/*! (c) Andrea Giammarchi (ISC) */
var uid = new Date * Math.random();
var templates = Object.create(null);
fix('bind');
fix('wire');
function fix(name) {
var method = hyperHTML[name];
hyperHTML[name] = function () {
var fn = method.apply(null, arguments);
return function () {
return fn.apply(null, tagArguments.apply(null, arguments));
};
};
}
function tagArguments() {
var length = arguments.length;
var template = [];
var args = [template];
if (length) {
var i = 0;
var mod = typeof arguments[i] === 'string' ? 0 : 1;
if (mod) template.push('');
while (i < length) {
((i + mod) % 2 ? args : template).push(arguments[i]);
i++;
}
if (template.length < args.length) template.push('');
var key = template.join(uid);
if (key in templates) {
args[0] = templates[key];
} else {
(templates[key] = template).raw = template;
}
}
return args;
}
}(hyperHTML));