@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/src/utilities.ts
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { micro as m, raf as r } from '@esportsplus/tasks';
|
|
2
|
-
import { Element as E } from './types';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
let getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor,
|
|
6
|
-
prototype,
|
|
7
|
-
template = document.createElement('template'),
|
|
8
|
-
t = document.createTextNode('');
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
prototype = DocumentFragment.prototype;
|
|
12
|
-
|
|
13
|
-
const append = prototype.append
|
|
14
|
-
|
|
15
|
-
// https://github.com/localvoid/ivi/blob/master/packages/ivi/src/client/core.ts#L38
|
|
16
|
-
prototype = Element.prototype;
|
|
17
|
-
|
|
18
|
-
const addEventListener = prototype.addEventListener;
|
|
19
|
-
|
|
20
|
-
const removeEventListener = prototype.removeEventListener;
|
|
21
|
-
|
|
22
|
-
const className = getOwnPropertyDescriptor(prototype, 'className')!.set!;
|
|
23
|
-
|
|
24
|
-
const innerHTML = getOwnPropertyDescriptor(prototype, 'innerHTML')!.set!;
|
|
25
|
-
|
|
26
|
-
const firstElementChild = getOwnPropertyDescriptor(prototype, 'firstElementChild')!.get!;
|
|
27
|
-
|
|
28
|
-
const nextElementSibling = getOwnPropertyDescriptor(prototype, 'nextElementSibling')!.get!;
|
|
29
|
-
|
|
30
|
-
const removeAttribute = prototype.removeAttribute;
|
|
31
|
-
|
|
32
|
-
const setAttribute = prototype.setAttribute;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
prototype = Node.prototype;
|
|
36
|
-
|
|
37
|
-
const cloneNode = prototype.cloneNode;
|
|
38
|
-
|
|
39
|
-
const firstChild = getOwnPropertyDescriptor(prototype, 'firstChild')!.get!;
|
|
40
|
-
|
|
41
|
-
const lastChild = getOwnPropertyDescriptor(prototype, 'lastChild')!.get!;
|
|
42
|
-
|
|
43
|
-
const nextSibling = getOwnPropertyDescriptor(prototype, 'nextSibling')!.get!;
|
|
44
|
-
|
|
45
|
-
const nodeValue = getOwnPropertyDescriptor(prototype, 'nodeValue')!.set!;
|
|
46
|
-
|
|
47
|
-
const parentElement = getOwnPropertyDescriptor(prototype, 'parentElement')!.get!;
|
|
48
|
-
|
|
49
|
-
const previousSibling = getOwnPropertyDescriptor(prototype, 'previousSibling')!.get!;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const fragment = (html: string) => {
|
|
53
|
-
innerHTML.call(template, html);
|
|
54
|
-
|
|
55
|
-
let { content } = template;
|
|
56
|
-
|
|
57
|
-
template = cloneNode.call(template) as HTMLTemplateElement;
|
|
58
|
-
|
|
59
|
-
return content;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const microtask = m();
|
|
63
|
-
|
|
64
|
-
const raf = r();
|
|
65
|
-
|
|
66
|
-
const text = (value: string) => {
|
|
67
|
-
let element = cloneNode.call(t);
|
|
68
|
-
|
|
69
|
-
if (value !== '') {
|
|
70
|
-
nodeValue.call(element, value);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return element as E;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
export {
|
|
78
|
-
addEventListener, append,
|
|
79
|
-
className, cloneNode,
|
|
80
|
-
firstChild, firstElementChild, fragment,
|
|
81
|
-
innerHTML,
|
|
82
|
-
lastChild,
|
|
83
|
-
microtask,
|
|
84
|
-
nextElementSibling, nextSibling, nodeValue,
|
|
85
|
-
parentElement, previousSibling,
|
|
86
|
-
raf, removeAttribute, removeEventListener,
|
|
87
|
-
setAttribute,
|
|
88
|
-
text
|
|
89
|
-
};
|