@esportsplus/template 0.16.1 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/attributes.js +27 -23
- package/build/constants.d.ts +13 -3
- package/build/constants.js +13 -3
- package/build/event.js +7 -7
- package/build/html/cache.js +1 -1
- package/build/html/hydrate.d.ts +2 -8
- package/build/html/hydrate.js +27 -78
- package/build/html/index.d.ts +2106 -5
- package/build/html/index.js +12 -4
- package/build/render.d.ts +1 -2
- package/build/render.js +6 -10
- package/build/slot/cleanup.d.ts +4 -0
- package/build/slot/cleanup.js +51 -0
- package/build/slot/effect.d.ts +3 -0
- package/build/slot/effect.js +51 -0
- package/build/slot/index.d.ts +3 -0
- package/build/slot/index.js +15 -0
- package/build/slot/reactive.d.ts +3 -0
- package/build/slot/reactive.js +117 -0
- package/build/slot/render.d.ts +2 -0
- package/build/slot/render.js +58 -0
- package/build/svg.d.ts +1 -2
- package/build/types.d.ts +20 -16
- package/build/utilities.d.ts +3 -3
- package/build/utilities.js +12 -12
- package/package.json +2 -2
- package/src/attributes.ts +30 -28
- package/src/constants.ts +31 -4
- package/src/event.ts +8 -8
- package/src/html/hydrate.ts +35 -107
- package/src/html/index.ts +16 -8
- package/src/render.ts +8 -12
- package/src/slot/cleanup.ts +74 -0
- package/src/slot/effect.ts +73 -0
- package/src/slot/index.ts +23 -0
- package/src/slot/reactive.ts +167 -0
- package/src/slot/render.ts +81 -0
- package/src/svg.ts +1 -2
- package/src/types.ts +24 -17
- package/src/utilities.ts +15 -13
- package/build/slot.d.ts +0 -21
- package/build/slot.js +0 -204
- package/src/slot.ts +0 -277
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { isArray } from '@esportsplus/utilities';
|
|
2
|
+
import {
|
|
3
|
+
RENDERABLE,
|
|
4
|
+
RENDERABLE_ARRAY, RENDERABLE_FRAGMENT, RENDERABLE_HTML_FRAGMENT, RENDERABLE_HTML_REACTIVE_ARRAY,
|
|
5
|
+
RENDERABLE_NODE, RENDERABLE_NODE_LIST, RENDERABLE_TEXT, RENDERABLE_VOID
|
|
6
|
+
} from '~/constants';
|
|
7
|
+
import { Element, Fragment, RenderableReactive, RenderableTemplate } from '~/types';
|
|
8
|
+
import { append, text } from '~/utilities';
|
|
9
|
+
import reactive from './reactive';
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
function type(input: unknown) {
|
|
13
|
+
if (input === false || input == null || input === '') {
|
|
14
|
+
return RENDERABLE_VOID;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (typeof input !== 'object') {
|
|
18
|
+
return RENDERABLE_TEXT;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (RENDERABLE in input) {
|
|
22
|
+
return input[RENDERABLE];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (isArray(input)) {
|
|
26
|
+
return RENDERABLE_ARRAY;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let nodeType = (input as any).nodeType;
|
|
30
|
+
|
|
31
|
+
if (nodeType === 11) {
|
|
32
|
+
return RENDERABLE_FRAGMENT;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (nodeType !== undefined) {
|
|
36
|
+
return RENDERABLE_NODE;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (input instanceof NodeList) {
|
|
40
|
+
return RENDERABLE_NODE_LIST;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
export default function render(anchor: Element, fragment: Fragment, input: unknown) {
|
|
46
|
+
let t = type(input);
|
|
47
|
+
|
|
48
|
+
switch (t) {
|
|
49
|
+
case RENDERABLE_VOID:
|
|
50
|
+
return;
|
|
51
|
+
|
|
52
|
+
case RENDERABLE_TEXT:
|
|
53
|
+
append.call(fragment, text(String(input)));
|
|
54
|
+
return;
|
|
55
|
+
|
|
56
|
+
case RENDERABLE_HTML_FRAGMENT:
|
|
57
|
+
append.call(fragment, (input as RenderableTemplate).fragment);
|
|
58
|
+
return;
|
|
59
|
+
|
|
60
|
+
case RENDERABLE_HTML_REACTIVE_ARRAY:
|
|
61
|
+
return reactive(anchor, input as RenderableReactive);
|
|
62
|
+
|
|
63
|
+
case RENDERABLE_ARRAY:
|
|
64
|
+
for (let i = 0, n = (input as unknown[]).length; i < n; i++) {
|
|
65
|
+
render(anchor, fragment, (input as unknown[])[i]);
|
|
66
|
+
}
|
|
67
|
+
return;
|
|
68
|
+
|
|
69
|
+
case RENDERABLE_FRAGMENT:
|
|
70
|
+
append.call(fragment, input as Fragment);
|
|
71
|
+
return;
|
|
72
|
+
|
|
73
|
+
case RENDERABLE_NODE:
|
|
74
|
+
append.call(fragment, input as Node);
|
|
75
|
+
return;
|
|
76
|
+
|
|
77
|
+
case RENDERABLE_NODE_LIST:
|
|
78
|
+
append.call(fragment, ...(input as NodeList));
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
};
|
package/src/svg.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import html from './html';
|
|
2
|
-
import { RenderableTemplate } from './types';
|
|
3
2
|
|
|
4
3
|
|
|
5
4
|
const svg = html.bind(null) as typeof html & {
|
|
6
|
-
sprite:
|
|
5
|
+
sprite: (symbol: string) => ReturnType<typeof html>
|
|
7
6
|
};
|
|
8
7
|
|
|
9
8
|
svg.sprite = (symbol: string) => {
|
package/src/types.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ReactiveArray } from '@esportsplus/reactivity';
|
|
2
|
-
import { RENDERABLE,
|
|
2
|
+
import { RENDERABLE, RENDERABLE_HTML_FRAGMENT, RENDERABLE_HTML_REACTIVE_ARRAY } from './constants';
|
|
3
3
|
import { firstChild } from './utilities';
|
|
4
4
|
import attributes from './attributes';
|
|
5
5
|
import slot from './slot';
|
|
6
|
+
import html from './html';
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
type Attribute = Primitive | Effect<Primitive | Primitive[]>;
|
|
@@ -24,38 +25,43 @@ type Attributes = {
|
|
|
24
25
|
|
|
25
26
|
type Effect<T> = () => EffectResponse<T>;
|
|
26
27
|
|
|
27
|
-
type EffectResponse<T> = T extends [] ?
|
|
28
|
+
type EffectResponse<T> = T extends [] ? (Primitive | Renderable)[] : Primitive | Renderable;
|
|
28
29
|
|
|
29
30
|
type Element = HTMLElement & Attributes & Record<PropertyKey, unknown>;
|
|
30
31
|
|
|
31
32
|
type Elements = Element[];
|
|
32
33
|
|
|
33
|
-
type Fragment = DocumentFragment | Node
|
|
34
|
+
type Fragment = (DocumentFragment | Node) & Record<PropertyKey, unknown>;
|
|
34
35
|
|
|
35
36
|
// Copied from '@esportsplus/utilities'
|
|
36
37
|
// - Importing from ^ causes 'cannot be named without a reference to...' error
|
|
37
38
|
type Primitive = bigint | boolean | null | number | string | undefined;
|
|
38
39
|
|
|
39
|
-
type Renderable
|
|
40
|
+
type Renderable = Fragment | RenderableReactive;
|
|
40
41
|
|
|
41
|
-
type RenderableReactive
|
|
42
|
-
[RENDERABLE]: typeof
|
|
43
|
-
|
|
42
|
+
type RenderableReactive = Readonly<{
|
|
43
|
+
[RENDERABLE]: typeof RENDERABLE_HTML_REACTIVE_ARRAY;
|
|
44
|
+
array: ReactiveArray<unknown[]>;
|
|
44
45
|
template: (
|
|
45
|
-
this:
|
|
46
|
-
...args: Parameters< Parameters<ReactiveArray<
|
|
47
|
-
) =>
|
|
48
|
-
values: ReactiveArray<T>;
|
|
46
|
+
this: ReactiveArray<unknown[]>,
|
|
47
|
+
...args: Parameters< Parameters<ReactiveArray<unknown[]>['map']>[0] >
|
|
48
|
+
) => ReturnType<typeof html>;
|
|
49
49
|
}>;
|
|
50
50
|
|
|
51
|
-
type RenderableTemplate
|
|
52
|
-
[RENDERABLE]: typeof
|
|
51
|
+
type RenderableTemplate = {
|
|
52
|
+
[RENDERABLE]: typeof RENDERABLE_HTML_FRAGMENT;
|
|
53
|
+
fragment: Fragment;
|
|
53
54
|
literals: TemplateStringsArray;
|
|
54
|
-
template: Template | null;
|
|
55
|
-
values: (RenderableValue<T> | RenderableValue<T>[])[];
|
|
56
55
|
};
|
|
57
56
|
|
|
58
|
-
type RenderableValue<T = unknown> = Attributes | Readonly<Attributes> | Readonly<Attributes[]> | Effect<T> | Primitive |
|
|
57
|
+
type RenderableValue<T = unknown> = Attributes | Readonly<Attributes> | Readonly<Attributes[]> | Effect<T> | Fragment | Primitive | RenderableReactive;
|
|
58
|
+
|
|
59
|
+
type RenderableValues = RenderableValue | RenderableValue[];
|
|
60
|
+
|
|
61
|
+
type SlotGroup = {
|
|
62
|
+
head: Element;
|
|
63
|
+
tail: Element;
|
|
64
|
+
};
|
|
59
65
|
|
|
60
66
|
type Template = {
|
|
61
67
|
fragment: DocumentFragment;
|
|
@@ -77,6 +83,7 @@ export type {
|
|
|
77
83
|
Attributes,
|
|
78
84
|
Effect, Element, Elements,
|
|
79
85
|
Fragment,
|
|
80
|
-
Renderable, RenderableReactive, RenderableTemplate, RenderableValue,
|
|
86
|
+
Renderable, RenderableReactive, RenderableTemplate, RenderableValue, RenderableValues,
|
|
87
|
+
SlotGroup,
|
|
81
88
|
Template
|
|
82
89
|
};
|
package/src/utilities.ts
CHANGED
|
@@ -2,7 +2,8 @@ import { micro as m, raf as r } from '@esportsplus/tasks';
|
|
|
2
2
|
import { Element as E } from './types';
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
let
|
|
5
|
+
let getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor,
|
|
6
|
+
prototype,
|
|
6
7
|
template = document.createElement('template'),
|
|
7
8
|
t = document.createTextNode('');
|
|
8
9
|
|
|
@@ -18,15 +19,13 @@ const addEventListener = prototype.addEventListener;
|
|
|
18
19
|
|
|
19
20
|
const removeEventListener = prototype.removeEventListener;
|
|
20
21
|
|
|
21
|
-
const className =
|
|
22
|
+
const className = getOwnPropertyDescriptor(prototype, 'className')!.set!;
|
|
22
23
|
|
|
23
|
-
const innerHTML =
|
|
24
|
+
const innerHTML = getOwnPropertyDescriptor(prototype, 'innerHTML')!.set!;
|
|
24
25
|
|
|
25
|
-
const firstElementChild =
|
|
26
|
+
const firstElementChild = getOwnPropertyDescriptor(prototype, 'firstElementChild')!.get!;
|
|
26
27
|
|
|
27
|
-
const nextElementSibling =
|
|
28
|
-
|
|
29
|
-
const prepend = prototype.prepend;
|
|
28
|
+
const nextElementSibling = getOwnPropertyDescriptor(prototype, 'nextElementSibling')!.get!;
|
|
30
29
|
|
|
31
30
|
const removeAttribute = prototype.removeAttribute;
|
|
32
31
|
|
|
@@ -37,15 +36,17 @@ prototype = Node.prototype;
|
|
|
37
36
|
|
|
38
37
|
const cloneNode = prototype.cloneNode;
|
|
39
38
|
|
|
40
|
-
const firstChild =
|
|
39
|
+
const firstChild = getOwnPropertyDescriptor(prototype, 'firstChild')!.get!;
|
|
40
|
+
|
|
41
|
+
const lastChild = getOwnPropertyDescriptor(prototype, 'lastChild')!.get!;
|
|
41
42
|
|
|
42
|
-
const nextSibling =
|
|
43
|
+
const nextSibling = getOwnPropertyDescriptor(prototype, 'nextSibling')!.get!;
|
|
43
44
|
|
|
44
|
-
const nodeValue =
|
|
45
|
+
const nodeValue = getOwnPropertyDescriptor(prototype, 'nodeValue')!.set!;
|
|
45
46
|
|
|
46
|
-
const parentElement =
|
|
47
|
+
const parentElement = getOwnPropertyDescriptor(prototype, 'parentElement')!.get!;
|
|
47
48
|
|
|
48
|
-
const
|
|
49
|
+
const previousSibling = getOwnPropertyDescriptor(prototype, 'previousSibling')!.get!;
|
|
49
50
|
|
|
50
51
|
|
|
51
52
|
const fragment = (html: string) => {
|
|
@@ -78,9 +79,10 @@ export {
|
|
|
78
79
|
className, cloneNode,
|
|
79
80
|
firstChild, firstElementChild, fragment,
|
|
80
81
|
innerHTML,
|
|
82
|
+
lastChild,
|
|
81
83
|
microtask,
|
|
82
84
|
nextElementSibling, nextSibling, nodeValue,
|
|
83
|
-
parentElement,
|
|
85
|
+
parentElement, previousSibling,
|
|
84
86
|
raf, removeAttribute, removeEventListener,
|
|
85
87
|
setAttribute,
|
|
86
88
|
text
|
package/build/slot.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Element, Elements, Fragment } from './types.js';
|
|
2
|
-
declare class Slot {
|
|
3
|
-
marker: Element;
|
|
4
|
-
nodes: Elements[];
|
|
5
|
-
text: Element | null;
|
|
6
|
-
constructor(marker: Element);
|
|
7
|
-
get length(): number;
|
|
8
|
-
set length(n: number);
|
|
9
|
-
anchor(index?: number): Element;
|
|
10
|
-
clear(): this;
|
|
11
|
-
pop(): this;
|
|
12
|
-
push(fragment: Fragment, ...nodes: Elements[]): this;
|
|
13
|
-
render(input: unknown, state?: number): this;
|
|
14
|
-
shift(): this;
|
|
15
|
-
splice(start: number, stop?: number, fragment?: Fragment, ...nodes: Elements[]): this;
|
|
16
|
-
unshift(fragment: Fragment, ...nodes: Elements[]): this;
|
|
17
|
-
}
|
|
18
|
-
declare const ondisconnect: (element: Element, fn: VoidFunction) => void;
|
|
19
|
-
declare const _default: (marker: Element, value: unknown) => void;
|
|
20
|
-
export default _default;
|
|
21
|
-
export { ondisconnect, Slot };
|
package/build/slot.js
DELETED
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import { effect } from '@esportsplus/reactivity';
|
|
2
|
-
import { isArray, isInstanceOf } from '@esportsplus/utilities';
|
|
3
|
-
import { EMPTY_FRAGMENT, RENDERABLE, RENDERABLE_REACTIVE } from './constants.js';
|
|
4
|
-
import { hydrate } from './html/index.js';
|
|
5
|
-
import { append, cloneNode, microtask, nodeValue, raf, text } from './utilities.js';
|
|
6
|
-
import queue from '@esportsplus/queue';
|
|
7
|
-
const CLEANUP_KEY = Symbol();
|
|
8
|
-
const CONNECTED = 0;
|
|
9
|
-
const HYDRATING = 1;
|
|
10
|
-
let cleanup = queue(64), scheduled = false;
|
|
11
|
-
function remove(groups) {
|
|
12
|
-
let group, item;
|
|
13
|
-
while (group = groups.pop()) {
|
|
14
|
-
while (item = group.pop()) {
|
|
15
|
-
if (CLEANUP_KEY in item) {
|
|
16
|
-
cleanup.add(item[CLEANUP_KEY]);
|
|
17
|
-
item[CLEANUP_KEY] = null;
|
|
18
|
-
}
|
|
19
|
-
item.remove();
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
if (!scheduled && cleanup.length) {
|
|
23
|
-
schedule();
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function render(anchor, elements, fragment, input, slot) {
|
|
27
|
-
if (input === false || input == null || input === '') {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
let type = typeof input;
|
|
31
|
-
if (type === 'object' && RENDERABLE in input) {
|
|
32
|
-
if (input[RENDERABLE] === RENDERABLE_REACTIVE) {
|
|
33
|
-
slot ??= new Slot(anchor);
|
|
34
|
-
hydrate.reactive(slot.nodes, fragment, input, slot);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
hydrate.static(elements, fragment, input);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
else if (type === 'string' || type === 'number') {
|
|
41
|
-
let element = text(type === 'string' ? input : String(input));
|
|
42
|
-
if (slot) {
|
|
43
|
-
slot.text = element;
|
|
44
|
-
}
|
|
45
|
-
append.call(fragment, element);
|
|
46
|
-
if (elements) {
|
|
47
|
-
elements.push([element]);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
else if (isArray(input)) {
|
|
51
|
-
for (let i = 0, n = input.length; i < n; i++) {
|
|
52
|
-
render(anchor, elements, fragment, input[i], slot);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
else if (isInstanceOf(input, NodeList)) {
|
|
56
|
-
append.call(fragment, ...input);
|
|
57
|
-
if (elements) {
|
|
58
|
-
elements.push([...input]);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
else if (isInstanceOf(input, Node)) {
|
|
62
|
-
append.call(fragment, input);
|
|
63
|
-
if (elements) {
|
|
64
|
-
elements.push([input]);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function schedule() {
|
|
69
|
-
if (scheduled) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
scheduled = true;
|
|
73
|
-
microtask.add(task);
|
|
74
|
-
}
|
|
75
|
-
function task() {
|
|
76
|
-
let fn, fns;
|
|
77
|
-
while (fns = cleanup.next()) {
|
|
78
|
-
try {
|
|
79
|
-
while (fn = fns.pop()) {
|
|
80
|
-
fn();
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
catch { }
|
|
84
|
-
}
|
|
85
|
-
scheduled = false;
|
|
86
|
-
if (cleanup.length) {
|
|
87
|
-
schedule();
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
class Slot {
|
|
91
|
-
marker;
|
|
92
|
-
nodes;
|
|
93
|
-
text = null;
|
|
94
|
-
constructor(marker) {
|
|
95
|
-
ondisconnect(marker, () => this.clear());
|
|
96
|
-
this.marker = marker;
|
|
97
|
-
this.nodes = [];
|
|
98
|
-
}
|
|
99
|
-
get length() {
|
|
100
|
-
return this.nodes.length;
|
|
101
|
-
}
|
|
102
|
-
set length(n) {
|
|
103
|
-
if (n >= this.nodes.length) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
else if (n === 0) {
|
|
107
|
-
this.clear();
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
this.splice(n);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
anchor(index = this.nodes.length - 1) {
|
|
114
|
-
let nodes = this.nodes[index];
|
|
115
|
-
return nodes ? nodes[nodes.length - 1] : this.marker;
|
|
116
|
-
}
|
|
117
|
-
clear() {
|
|
118
|
-
if (this.text) {
|
|
119
|
-
this.nodes.push([this.text]);
|
|
120
|
-
this.text = null;
|
|
121
|
-
}
|
|
122
|
-
remove(this.nodes);
|
|
123
|
-
return this;
|
|
124
|
-
}
|
|
125
|
-
pop() {
|
|
126
|
-
let group = this.nodes.pop();
|
|
127
|
-
if (group) {
|
|
128
|
-
remove([group]);
|
|
129
|
-
}
|
|
130
|
-
return this;
|
|
131
|
-
}
|
|
132
|
-
push(fragment, ...nodes) {
|
|
133
|
-
this.anchor().after(fragment);
|
|
134
|
-
this.nodes.push(...nodes);
|
|
135
|
-
return this;
|
|
136
|
-
}
|
|
137
|
-
render(input, state = HYDRATING) {
|
|
138
|
-
let type = typeof input;
|
|
139
|
-
if (type === 'function') {
|
|
140
|
-
ondisconnect(this.marker, effect(() => {
|
|
141
|
-
let v = input();
|
|
142
|
-
if (state === HYDRATING) {
|
|
143
|
-
this.render(v, state);
|
|
144
|
-
state = CONNECTED;
|
|
145
|
-
}
|
|
146
|
-
else if (state === CONNECTED) {
|
|
147
|
-
raf.add(() => {
|
|
148
|
-
this.render(v, state);
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
}));
|
|
152
|
-
return this;
|
|
153
|
-
}
|
|
154
|
-
let text = this.text;
|
|
155
|
-
if (text && text.isConnected && (input == null || type !== 'object')) {
|
|
156
|
-
nodeValue.call(text, (type === 'number' || type === 'string') ? input : '');
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
this.clear();
|
|
160
|
-
let fragment = cloneNode.call(EMPTY_FRAGMENT);
|
|
161
|
-
render(this.marker, this.nodes, fragment, input, this);
|
|
162
|
-
this.marker.after(fragment);
|
|
163
|
-
}
|
|
164
|
-
return this;
|
|
165
|
-
}
|
|
166
|
-
shift() {
|
|
167
|
-
let group = this.nodes.shift();
|
|
168
|
-
if (group) {
|
|
169
|
-
remove([group]);
|
|
170
|
-
}
|
|
171
|
-
return this;
|
|
172
|
-
}
|
|
173
|
-
splice(start, stop = this.nodes.length, fragment, ...nodes) {
|
|
174
|
-
if (!fragment) {
|
|
175
|
-
remove(this.nodes.splice(start, stop));
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
this.anchor(start).after(fragment);
|
|
179
|
-
remove(this.nodes.splice(start, stop, ...nodes));
|
|
180
|
-
}
|
|
181
|
-
return this;
|
|
182
|
-
}
|
|
183
|
-
unshift(fragment, ...nodes) {
|
|
184
|
-
this.marker.after(fragment);
|
|
185
|
-
this.nodes.unshift(...nodes);
|
|
186
|
-
return this;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
const ondisconnect = (element, fn) => {
|
|
190
|
-
(element[CLEANUP_KEY] ??= []).push(fn);
|
|
191
|
-
};
|
|
192
|
-
export default (marker, value) => {
|
|
193
|
-
let type = typeof value;
|
|
194
|
-
if (type === 'function') {
|
|
195
|
-
new Slot(marker).render(value);
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
let fragment = cloneNode.call(EMPTY_FRAGMENT);
|
|
199
|
-
render(marker, null, fragment, value);
|
|
200
|
-
marker.after(fragment);
|
|
201
|
-
}
|
|
202
|
-
;
|
|
203
|
-
};
|
|
204
|
-
export { ondisconnect, Slot };
|