@esportsplus/template 0.17.0 → 0.18.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 +2 -1
- package/build/constants.js +1 -1
- package/build/event.js +47 -45
- package/build/html/hydrate.js +1 -1
- package/build/html/index.js +2 -2
- package/build/html/{cache.d.ts → parser.d.ts} +1 -1
- package/build/html/{cache.js → parser.js} +5 -3
- package/build/render.js +3 -2
- package/build/slot/cleanup.js +2 -1
- package/build/slot/effect.js +12 -7
- package/build/slot/index.js +1 -8
- package/build/slot/reactive.d.ts +2 -2
- package/build/slot/reactive.js +12 -4
- package/build/slot/render.d.ts +2 -2
- package/build/slot/render.js +36 -13
- package/build/types.d.ts +2 -2
- package/build/utilities/element.d.ts +11 -0
- package/build/utilities/element.js +9 -0
- package/build/utilities/fragment.d.ts +3 -0
- package/build/utilities/fragment.js +11 -0
- package/build/utilities/node.d.ts +8 -0
- package/build/utilities/node.js +9 -0
- package/build/utilities/queue.d.ts +3 -0
- package/build/utilities/queue.js +4 -0
- package/build/utilities/text.d.ts +3 -0
- package/build/utilities/text.js +9 -0
- package/package.json +1 -1
- package/src/attributes.ts +2 -1
- package/src/constants.ts +1 -1
- package/src/event.ts +55 -52
- package/src/html/hydrate.ts +1 -1
- package/src/html/index.ts +2 -2
- package/src/html/{cache.ts → parser.ts} +5 -3
- package/src/render.ts +3 -3
- package/src/slot/cleanup.ts +2 -2
- package/src/slot/effect.ts +13 -12
- package/src/slot/index.ts +3 -14
- package/src/slot/reactive.ts +17 -7
- package/src/slot/render.ts +51 -15
- package/src/types.ts +2 -2
- package/src/utilities/element.ts +28 -0
- package/src/utilities/fragment.ts +22 -0
- package/src/utilities/node.ts +26 -0
- package/src/utilities/queue.ts +9 -0
- package/src/utilities/text.ts +16 -0
- package/build/utilities.d.ts +0 -28
- package/build/utilities.js +0 -37
- package/src/utilities.ts +0 -89
package/build/attributes.js
CHANGED
|
@@ -2,7 +2,8 @@ import { effect } from '@esportsplus/reactivity';
|
|
|
2
2
|
import { isArray, isObject, isString } from '@esportsplus/utilities';
|
|
3
3
|
import { ondisconnect } from './slot/cleanup.js';
|
|
4
4
|
import { STATE_HYDRATING, STATE_NONE, STATE_WAITING } from './constants.js';
|
|
5
|
-
import { className,
|
|
5
|
+
import { className, removeAttribute, setAttribute } from './utilities/element.js';
|
|
6
|
+
import { raf } from './utilities/queue.js';
|
|
6
7
|
import q from '@esportsplus/queue';
|
|
7
8
|
import event from './event.js';
|
|
8
9
|
const EFFECT = Symbol();
|
package/build/constants.js
CHANGED
package/build/event.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { root } from '@esportsplus/reactivity';
|
|
2
2
|
import { defineProperty } from '@esportsplus/utilities';
|
|
3
|
-
import { addEventListener
|
|
3
|
+
import { addEventListener } from './utilities/element.js';
|
|
4
|
+
import { parentElement } from './utilities/node.js';
|
|
5
|
+
import { raf } from './utilities/queue.js';
|
|
4
6
|
import { ondisconnect } from './slot/cleanup.js';
|
|
5
7
|
let capture = new Set(['onblur', 'onfocus', 'onscroll']), controllers = new Map(), keys = {}, passive = new Set([
|
|
6
8
|
'onmousedown', 'onmouseenter', 'onmouseleave', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'onmousewheel',
|
|
@@ -11,6 +13,49 @@ let capture = new Set(['onblur', 'onfocus', 'onscroll']), controllers = new Map(
|
|
|
11
13
|
['onmousemove', 'onmousewheel', 'onscroll', 'ontouchend', 'ontouchmove', 'ontouchstart', 'onwheel'].map(event => {
|
|
12
14
|
controllers.set(event, null);
|
|
13
15
|
});
|
|
16
|
+
function register(element, event) {
|
|
17
|
+
let controller = controllers.get(event), signal;
|
|
18
|
+
if (controller === null) {
|
|
19
|
+
let { abort, signal } = new AbortController();
|
|
20
|
+
controllers.set(event, controller = {
|
|
21
|
+
abort,
|
|
22
|
+
signal,
|
|
23
|
+
listeners: 0,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
if (controller) {
|
|
27
|
+
controller.listeners++;
|
|
28
|
+
ondisconnect(element, () => {
|
|
29
|
+
if (--controller.listeners) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
controller.abort();
|
|
33
|
+
controllers.set(event, null);
|
|
34
|
+
});
|
|
35
|
+
signal = controller.signal;
|
|
36
|
+
}
|
|
37
|
+
let key = keys[event] = Symbol();
|
|
38
|
+
addEventListener.call(window.document, event.slice(2), (e) => {
|
|
39
|
+
let node = e.target;
|
|
40
|
+
while (node) {
|
|
41
|
+
if (key in node) {
|
|
42
|
+
defineProperty(e, 'currentTarget', {
|
|
43
|
+
configurable: true,
|
|
44
|
+
get() {
|
|
45
|
+
return node || window.document;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return node[key].call(node, e);
|
|
49
|
+
}
|
|
50
|
+
node = parentElement.call(node);
|
|
51
|
+
}
|
|
52
|
+
}, {
|
|
53
|
+
capture: capture.has(event),
|
|
54
|
+
passive: passive.has(event),
|
|
55
|
+
signal
|
|
56
|
+
});
|
|
57
|
+
return key;
|
|
58
|
+
}
|
|
14
59
|
export default (element, event, listener) => {
|
|
15
60
|
if (event === 'onconnect') {
|
|
16
61
|
let retry = 60, task = () => {
|
|
@@ -34,48 +79,5 @@ export default (element, event, listener) => {
|
|
|
34
79
|
root(() => listener(element));
|
|
35
80
|
return;
|
|
36
81
|
}
|
|
37
|
-
|
|
38
|
-
if (controller === null) {
|
|
39
|
-
let { abort, signal } = new AbortController();
|
|
40
|
-
controllers.set(event, controller = {
|
|
41
|
-
abort,
|
|
42
|
-
signal,
|
|
43
|
-
listeners: 0,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
if (controller) {
|
|
47
|
-
controller.listeners++;
|
|
48
|
-
ondisconnect(element, () => {
|
|
49
|
-
if (--controller.listeners) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
controller.abort();
|
|
53
|
-
controllers.set(event, null);
|
|
54
|
-
});
|
|
55
|
-
signal = controller.signal;
|
|
56
|
-
}
|
|
57
|
-
let key = keys[event];
|
|
58
|
-
if (!key) {
|
|
59
|
-
key = keys[event] = Symbol();
|
|
60
|
-
addEventListener.call(window.document, event.slice(2), (e) => {
|
|
61
|
-
let node = e.target;
|
|
62
|
-
while (node) {
|
|
63
|
-
if (key in node) {
|
|
64
|
-
defineProperty(e, 'currentTarget', {
|
|
65
|
-
configurable: true,
|
|
66
|
-
get() {
|
|
67
|
-
return node || window.document;
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
return node[key].call(node, e);
|
|
71
|
-
}
|
|
72
|
-
node = parentElement.call(node);
|
|
73
|
-
}
|
|
74
|
-
}, {
|
|
75
|
-
capture: capture.has(event),
|
|
76
|
-
passive: passive.has(event),
|
|
77
|
-
signal
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
element[key] = listener;
|
|
82
|
+
element[keys[event] || register(element, event)] = listener;
|
|
81
83
|
};
|
package/build/html/hydrate.js
CHANGED
package/build/html/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { RENDERABLE, RENDERABLE_HTML_FRAGMENT, RENDERABLE_HTML_REACTIVE_ARRAY } from '../constants.js';
|
|
2
2
|
import hydrate from './hydrate.js';
|
|
3
|
-
import
|
|
3
|
+
import parser from './parser.js';
|
|
4
4
|
const html = (literals, ...values) => {
|
|
5
5
|
return {
|
|
6
6
|
[RENDERABLE]: RENDERABLE_HTML_FRAGMENT,
|
|
7
|
-
fragment: hydrate(
|
|
7
|
+
fragment: hydrate(parser.parse(literals), values),
|
|
8
8
|
literals
|
|
9
9
|
};
|
|
10
10
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { NODE_CLOSING, NODE_ELEMENT, NODE_SLOT, NODE_VOID, NODE_WHITELIST, REGEX_EMPTY_TEXT_NODES, REGEX_SLOT_NODES, SLOT_HTML, SLOT_MARKER, SLOT_MARKER_LENGTH } from '../constants.js';
|
|
2
|
-
import {
|
|
2
|
+
import { firstElementChild, nextElementSibling } from '../utilities/element.js';
|
|
3
|
+
import { fragment } from '../utilities/fragment.js';
|
|
4
|
+
import { firstChild, nextSibling } from '../utilities/node.js';
|
|
3
5
|
import { spread } from '../attributes.js';
|
|
4
6
|
import s from '../slot/index.js';
|
|
5
7
|
let cache = new WeakMap();
|
|
@@ -94,7 +96,7 @@ function set(literals, html, slots = null) {
|
|
|
94
96
|
cache.set(literals, template);
|
|
95
97
|
return template;
|
|
96
98
|
}
|
|
97
|
-
const
|
|
99
|
+
const parse = (literals) => {
|
|
98
100
|
return cache.get(literals) || build(literals);
|
|
99
101
|
};
|
|
100
|
-
export default {
|
|
102
|
+
export default { parse };
|
package/build/render.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { SLOT_HTML } from './constants.js';
|
|
2
|
-
import {
|
|
2
|
+
import { fragment } from './utilities/fragment.js';
|
|
3
|
+
import { firstChild, nodeValue } from './utilities/node.js';
|
|
3
4
|
import slot from './slot/index.js';
|
|
4
5
|
let anchor, marker = firstChild.call(fragment(SLOT_HTML));
|
|
5
6
|
export default (parent, renderable) => {
|
|
6
7
|
nodeValue.call(parent, '');
|
|
7
8
|
parent.append(anchor = marker.cloneNode());
|
|
8
|
-
|
|
9
|
+
slot(anchor, renderable);
|
|
9
10
|
};
|
package/build/slot/cleanup.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import queue from '@esportsplus/queue';
|
|
2
2
|
import { CLEANUP } from '../constants.js';
|
|
3
|
-
import { microtask
|
|
3
|
+
import { microtask } from '../utilities/queue.js';
|
|
4
|
+
import { previousSibling } from '../utilities/node.js';
|
|
4
5
|
let cleanup = queue(64), scheduled = false;
|
|
5
6
|
function schedule() {
|
|
6
7
|
if (!cleanup.length || scheduled) {
|
package/build/slot/effect.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { effect } from '@esportsplus/reactivity';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { STATE_HYDRATING, STATE_NONE } from '../constants.js';
|
|
3
|
+
import { firstChild, lastChild, nodeValue } from '../utilities/node.js';
|
|
4
|
+
import { raf } from '../utilities/queue.js';
|
|
4
5
|
import { ondisconnect } from '../slot/cleanup.js';
|
|
5
6
|
import { remove } from './cleanup.js';
|
|
7
|
+
import text from '../utilities/text.js';
|
|
6
8
|
import render from './render.js';
|
|
7
|
-
function update(anchor,
|
|
9
|
+
function update(anchor, value) {
|
|
8
10
|
let type = typeof value;
|
|
9
11
|
if (this.group) {
|
|
10
12
|
remove([this.group]);
|
|
@@ -23,7 +25,10 @@ function update(anchor, fragment, value) {
|
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
27
|
else {
|
|
26
|
-
render(anchor,
|
|
28
|
+
let fragment = render(anchor, value);
|
|
29
|
+
if (!fragment) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
27
32
|
this.group = {
|
|
28
33
|
head: firstChild.call(fragment),
|
|
29
34
|
tail: lastChild.call(fragment)
|
|
@@ -35,16 +40,16 @@ export default (anchor, fn) => {
|
|
|
35
40
|
let context = {
|
|
36
41
|
group: undefined,
|
|
37
42
|
textnode: undefined
|
|
38
|
-
},
|
|
43
|
+
}, state = STATE_HYDRATING;
|
|
39
44
|
ondisconnect(anchor, effect(() => {
|
|
40
45
|
let value = fn();
|
|
41
46
|
if (state === STATE_HYDRATING) {
|
|
42
|
-
update.call(context, anchor,
|
|
47
|
+
update.call(context, anchor, value);
|
|
43
48
|
state = STATE_NONE;
|
|
44
49
|
}
|
|
45
50
|
else if (state === STATE_NONE) {
|
|
46
51
|
raf.add(() => {
|
|
47
|
-
update.call(context, anchor,
|
|
52
|
+
update.call(context, anchor, value);
|
|
48
53
|
});
|
|
49
54
|
}
|
|
50
55
|
}));
|
package/build/slot/index.js
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import { EMPTY_FRAGMENT } from '../constants.js';
|
|
2
|
-
import { cloneNode } from '../utilities.js';
|
|
3
1
|
import effect from './effect.js';
|
|
4
2
|
import render from './render.js';
|
|
5
|
-
function slot(anchor, input) {
|
|
6
|
-
let fragment = cloneNode.call(EMPTY_FRAGMENT);
|
|
7
|
-
render(anchor, fragment, input);
|
|
8
|
-
anchor.after(fragment);
|
|
9
|
-
}
|
|
10
3
|
export default (anchor, value) => {
|
|
11
4
|
if (typeof value === 'function') {
|
|
12
5
|
return effect(anchor, value);
|
|
13
6
|
}
|
|
14
|
-
|
|
7
|
+
anchor.after(render(anchor, value));
|
|
15
8
|
};
|
package/build/slot/reactive.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { RenderableReactive } from '../types.js';
|
|
2
|
-
declare const _default: (anchor: Element, renderable: RenderableReactive) =>
|
|
1
|
+
import { Fragment, RenderableReactive } from '../types.js';
|
|
2
|
+
declare const _default: (anchor: Element, renderable: RenderableReactive) => Fragment;
|
|
3
3
|
export default _default;
|
package/build/slot/reactive.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { root } from '@esportsplus/reactivity';
|
|
2
2
|
import { EMPTY_FRAGMENT } from '../constants.js';
|
|
3
|
-
import { append
|
|
3
|
+
import { append } from '../utilities/fragment.js';
|
|
4
|
+
import { cloneNode, firstChild, lastChild } from '../utilities/node.js';
|
|
4
5
|
import { remove } from './cleanup.js';
|
|
5
6
|
class ReactiveArraySlot {
|
|
6
7
|
array;
|
|
@@ -72,9 +73,10 @@ class ReactiveArraySlot {
|
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
push(items) {
|
|
75
|
-
let anchor = this.anchor(), array = this.array;
|
|
76
|
+
let anchor = this.anchor(), array = this.array, length = this.nodes.length;
|
|
77
|
+
this.nodes.length = length + items.length;
|
|
76
78
|
for (let i = 0, n = items.length; i < n; i++) {
|
|
77
|
-
this.nodes
|
|
79
|
+
this.nodes[i + length] = this.template.call(array, items[i], i);
|
|
78
80
|
}
|
|
79
81
|
anchor.after(this.fragment);
|
|
80
82
|
}
|
|
@@ -113,5 +115,11 @@ class ReactiveArraySlot {
|
|
|
113
115
|
}
|
|
114
116
|
}
|
|
115
117
|
export default (anchor, renderable) => {
|
|
116
|
-
new ReactiveArraySlot(anchor,
|
|
118
|
+
let { array, template } = renderable, slot = new ReactiveArraySlot(anchor, array, template);
|
|
119
|
+
if (array.length) {
|
|
120
|
+
root(() => {
|
|
121
|
+
slot.nodes = array.map(slot.template);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
return slot.fragment;
|
|
117
125
|
};
|
package/build/slot/render.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Element
|
|
2
|
-
export default function render(anchor: Element,
|
|
1
|
+
import { Element } from '../types.js';
|
|
2
|
+
export default function render(anchor: Element, input: unknown): Node;
|
package/build/slot/render.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { isArray } from '@esportsplus/utilities';
|
|
2
|
-
import { RENDERABLE, RENDERABLE_ARRAY, RENDERABLE_FRAGMENT, RENDERABLE_HTML_FRAGMENT, RENDERABLE_HTML_REACTIVE_ARRAY, RENDERABLE_NODE, RENDERABLE_NODE_LIST, RENDERABLE_TEXT, RENDERABLE_VOID } from '../constants.js';
|
|
3
|
-
import {
|
|
2
|
+
import { EMPTY_FRAGMENT, RENDERABLE, RENDERABLE_ARRAY, RENDERABLE_FRAGMENT, RENDERABLE_HTML_FRAGMENT, RENDERABLE_HTML_REACTIVE_ARRAY, RENDERABLE_NODE, RENDERABLE_NODE_LIST, RENDERABLE_TEXT, RENDERABLE_VOID } from '../constants.js';
|
|
3
|
+
import { cloneNode } from '../utilities/node.js';
|
|
4
|
+
import { append } from '../utilities/fragment.js';
|
|
5
|
+
import text from '../utilities/text.js';
|
|
4
6
|
import reactive from './reactive.js';
|
|
5
7
|
function type(input) {
|
|
6
8
|
if (input === false || input == null || input === '') {
|
|
@@ -25,34 +27,55 @@ function type(input) {
|
|
|
25
27
|
if (input instanceof NodeList) {
|
|
26
28
|
return RENDERABLE_NODE_LIST;
|
|
27
29
|
}
|
|
30
|
+
return RENDERABLE_TEXT;
|
|
28
31
|
}
|
|
29
|
-
|
|
32
|
+
function loop(fragment, input) {
|
|
30
33
|
let t = type(input);
|
|
31
34
|
switch (t) {
|
|
35
|
+
case RENDERABLE_HTML_REACTIVE_ARRAY:
|
|
36
|
+
throw new Error('@esportsplus/template: reactive arrays cannot be defined within an slot array value');
|
|
32
37
|
case RENDERABLE_VOID:
|
|
33
38
|
return;
|
|
34
|
-
case
|
|
35
|
-
|
|
39
|
+
case RENDERABLE_ARRAY:
|
|
40
|
+
for (let i = 0, n = input.length; i < n; i++) {
|
|
41
|
+
loop(fragment, input[i]);
|
|
42
|
+
}
|
|
36
43
|
return;
|
|
37
|
-
case
|
|
38
|
-
append.call(fragment, input
|
|
44
|
+
case RENDERABLE_NODE_LIST:
|
|
45
|
+
append.call(fragment, ...input);
|
|
39
46
|
return;
|
|
47
|
+
default:
|
|
48
|
+
append.call(fragment, input);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
let scratchpad = cloneNode.call(EMPTY_FRAGMENT);
|
|
53
|
+
export default function render(anchor, input) {
|
|
54
|
+
let fragment = scratchpad, t = type(input);
|
|
55
|
+
switch (t) {
|
|
56
|
+
case RENDERABLE_VOID:
|
|
57
|
+
break;
|
|
58
|
+
case RENDERABLE_TEXT:
|
|
59
|
+
append.call(fragment, text(input));
|
|
60
|
+
break;
|
|
61
|
+
case RENDERABLE_HTML_FRAGMENT:
|
|
62
|
+
return input.fragment;
|
|
40
63
|
case RENDERABLE_HTML_REACTIVE_ARRAY:
|
|
41
64
|
return reactive(anchor, input);
|
|
42
65
|
case RENDERABLE_ARRAY:
|
|
43
66
|
for (let i = 0, n = input.length; i < n; i++) {
|
|
44
|
-
|
|
67
|
+
loop(fragment, input[i]);
|
|
45
68
|
}
|
|
46
|
-
|
|
69
|
+
break;
|
|
47
70
|
case RENDERABLE_FRAGMENT:
|
|
48
|
-
|
|
49
|
-
return;
|
|
71
|
+
return input;
|
|
50
72
|
case RENDERABLE_NODE:
|
|
51
73
|
append.call(fragment, input);
|
|
52
|
-
|
|
74
|
+
break;
|
|
53
75
|
case RENDERABLE_NODE_LIST:
|
|
54
76
|
append.call(fragment, ...input);
|
|
55
|
-
|
|
77
|
+
break;
|
|
56
78
|
}
|
|
79
|
+
return fragment;
|
|
57
80
|
}
|
|
58
81
|
;
|
package/build/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactiveArray } from '@esportsplus/reactivity';
|
|
2
2
|
import { RENDERABLE, RENDERABLE_HTML_FRAGMENT, RENDERABLE_HTML_REACTIVE_ARRAY } from './constants.js';
|
|
3
|
-
import { firstChild } from './utilities.js';
|
|
3
|
+
import { firstChild } from './utilities/node.js';
|
|
4
4
|
import attributes from './attributes.js';
|
|
5
5
|
import slot from './slot/index.js';
|
|
6
6
|
import html from './html/index.js';
|
|
@@ -23,7 +23,7 @@ type Element = HTMLElement & Attributes & Record<PropertyKey, unknown>;
|
|
|
23
23
|
type Elements = Element[];
|
|
24
24
|
type Fragment = (DocumentFragment | Node) & Record<PropertyKey, unknown>;
|
|
25
25
|
type Primitive = bigint | boolean | null | number | string | undefined;
|
|
26
|
-
type Renderable = Fragment | RenderableReactive;
|
|
26
|
+
type Renderable = Fragment | Primitive | RenderableReactive | RenderableTemplate;
|
|
27
27
|
type RenderableReactive = Readonly<{
|
|
28
28
|
[RENDERABLE]: typeof RENDERABLE_HTML_REACTIVE_ARRAY;
|
|
29
29
|
array: ReactiveArray<unknown[]>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const addEventListener: {
|
|
2
|
+
<K extends keyof ElementEventMap>(type: K, listener: (this: Element, ev: ElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
3
|
+
(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
4
|
+
};
|
|
5
|
+
declare const className: (v: any) => void;
|
|
6
|
+
declare const innerHTML: (v: any) => void;
|
|
7
|
+
declare const firstElementChild: () => any;
|
|
8
|
+
declare const nextElementSibling: () => any;
|
|
9
|
+
declare const removeAttribute: (qualifiedName: string) => void;
|
|
10
|
+
declare const setAttribute: (qualifiedName: string, value: string) => void;
|
|
11
|
+
export { addEventListener, className, innerHTML, firstElementChild, nextElementSibling, removeAttribute, setAttribute };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
let getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor, prototype = Element.prototype;
|
|
2
|
+
const addEventListener = prototype.addEventListener;
|
|
3
|
+
const className = getOwnPropertyDescriptor(prototype, 'className').set;
|
|
4
|
+
const innerHTML = getOwnPropertyDescriptor(prototype, 'innerHTML').set;
|
|
5
|
+
const firstElementChild = getOwnPropertyDescriptor(prototype, 'firstElementChild').get;
|
|
6
|
+
const nextElementSibling = getOwnPropertyDescriptor(prototype, 'nextElementSibling').get;
|
|
7
|
+
const removeAttribute = prototype.removeAttribute;
|
|
8
|
+
const setAttribute = prototype.setAttribute;
|
|
9
|
+
export { addEventListener, className, innerHTML, firstElementChild, nextElementSibling, removeAttribute, setAttribute };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { innerHTML } from './element.js';
|
|
2
|
+
import { cloneNode } from './node.js';
|
|
3
|
+
let prototype = DocumentFragment.prototype, template = document.createElement('template');
|
|
4
|
+
const append = prototype.append;
|
|
5
|
+
const fragment = (html) => {
|
|
6
|
+
innerHTML.call(template, html);
|
|
7
|
+
let content = template.content;
|
|
8
|
+
template = cloneNode.call(template);
|
|
9
|
+
return content;
|
|
10
|
+
};
|
|
11
|
+
export { append, fragment };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare const cloneNode: (subtree?: boolean) => Node;
|
|
2
|
+
declare const firstChild: () => any;
|
|
3
|
+
declare const lastChild: () => any;
|
|
4
|
+
declare const nextSibling: () => any;
|
|
5
|
+
declare const nodeValue: (v: any) => void;
|
|
6
|
+
declare const parentElement: () => any;
|
|
7
|
+
declare const previousSibling: () => any;
|
|
8
|
+
export { cloneNode, firstChild, lastChild, nextSibling, nodeValue, parentElement, previousSibling };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
let getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor, prototype = Node.prototype;
|
|
2
|
+
const cloneNode = prototype.cloneNode;
|
|
3
|
+
const firstChild = getOwnPropertyDescriptor(prototype, 'firstChild').get;
|
|
4
|
+
const lastChild = getOwnPropertyDescriptor(prototype, 'lastChild').get;
|
|
5
|
+
const nextSibling = getOwnPropertyDescriptor(prototype, 'nextSibling').get;
|
|
6
|
+
const nodeValue = getOwnPropertyDescriptor(prototype, 'nodeValue').set;
|
|
7
|
+
const parentElement = getOwnPropertyDescriptor(prototype, 'parentElement').get;
|
|
8
|
+
const previousSibling = getOwnPropertyDescriptor(prototype, 'previousSibling').get;
|
|
9
|
+
export { cloneNode, firstChild, lastChild, nextSibling, nodeValue, parentElement, previousSibling };
|
package/package.json
CHANGED
package/src/attributes.ts
CHANGED
|
@@ -3,7 +3,8 @@ import { isArray, isObject, isString } from '@esportsplus/utilities';
|
|
|
3
3
|
import { ondisconnect } from './slot/cleanup';
|
|
4
4
|
import { STATE_HYDRATING, STATE_NONE, STATE_WAITING } from './constants';
|
|
5
5
|
import { Attributes, Element } from './types';
|
|
6
|
-
import { className,
|
|
6
|
+
import { className, removeAttribute, setAttribute } from './utilities/element';
|
|
7
|
+
import { raf } from './utilities/queue';
|
|
7
8
|
import q from '@esportsplus/queue';
|
|
8
9
|
import event from './event';
|
|
9
10
|
|
package/src/constants.ts
CHANGED