-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathindex.js
43 lines (36 loc) · 1.02 KB
/
index.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
41
42
43
/*
* Sinuous by Wesley Luyten (@luwes).
* Really ties all the packages together.
*/
import {
o,
observable,
computed,
subscribe,
cleanup,
root,
sample,
} from './observable.js';
import { api } from './h.js';
import htm from './htm.js';
// Minified this is actually smaller than Object.assign(api, { ... })
api.subscribe = subscribe;
api.cleanup = cleanup;
api.root = root;
api.sample = sample;
api.hs = (...args) => {
const prevIsSvg = api.s;
api.s = true;
const el = h(...args);
api.s = prevIsSvg;
return el;
};
// Makes it possible to intercept `h` calls and customize.
export const h = (...args) => api.h.apply(api.h, args);
// Makes it possible to intercept `hs` calls and customize.
export const hs = (...args) => api.hs.apply(api.hs, args);
// `export const html = htm.bind(h)` is not tree-shakeable!
export const html = (...args) => htm.apply(h, args);
// `export const svg = htm.bind(hs)` is not tree-shakeable!
export const svg = (...args) => htm.apply(hs, args);
export { api, o, observable, computed };