-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmini-van-0.3.7.nomodule.js
More file actions
32 lines (31 loc) · 1.05 KB
/
mini-van-0.3.7.nomodule.js
File metadata and controls
32 lines (31 loc) · 1.05 KB
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
(() => {
// mini-van.js
var Obj = Object;
var _undefined;
var vanWithDoc = (doc) => {
let toDom = (v) => v.nodeType ? v : doc.createTextNode(v);
let _result = {
add: (dom, ...children) => {
for (let child of children.flat(Infinity))
if (child != _undefined)
dom.appendChild(toDom(child));
return dom;
},
tags: new Proxy((name, ...args) => {
let [props, ...children] = args[0]?.constructor === Obj ? args : [{}, ...args];
let dom = doc.createElement(name);
for (let [k, v] of Obj.entries(props))
dom[k] !== void 0 ? dom[k] = v : dom.setAttribute(k, v);
return _result.add(dom, ...children);
}, { get: (tag, name) => tag.bind(null, name) }),
"html": (...args) => "<!DOCTYPE html>" + _result.tags.html(...args).outerHTML
};
return _result;
};
var mini_van_default = {
"vanWithDoc": vanWithDoc,
...vanWithDoc(typeof window !== "undefined" ? window.document : null)
};
// mini-van.forbundle.js
window.van = mini_van_default;
})();