-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmini-van-0.3.2.nomodule.js
More file actions
25 lines (24 loc) · 974 Bytes
/
mini-van-0.3.2.nomodule.js
File metadata and controls
25 lines (24 loc) · 974 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
(() => {
// mini-van.js
var Obj = Object;
var vanWithDoc = (doc) => {
let toDom = (v) => v.nodeType ? v : doc.createTextNode(v);
let _result = {
add: (dom, ...children) => (children.flat(Infinity).forEach((child) => dom.appendChild(toDom(child))), dom),
tags: new Proxy((name, ...args) => {
let [props, ...children] = args[0]?.constructor === Obj ? args : [{}, ...args];
let dom = doc.createElement(name);
Obj.entries(props).forEach(([k, v]) => 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;
})();