@esportsplus/template 0.23.0 → 0.23.2
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 +22 -40
- package/package.json +1 -1
- package/src/attributes.ts +26 -55
- package/src/slot/index.ts +1 -1
package/build/attributes.js
CHANGED
|
@@ -27,52 +27,34 @@ function apply(element, name, value) {
|
|
|
27
27
|
function context(element) {
|
|
28
28
|
return (element[STORE] ??= { element });
|
|
29
29
|
}
|
|
30
|
-
function list(ctx, element, id, name,
|
|
30
|
+
function list(ctx, element, id, name, state, value) {
|
|
31
31
|
if (value == null || value === false || value === '') {
|
|
32
32
|
value = '';
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
if (id === null && (!value || typeof value !== 'string')) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
let delimiter = delimiters[name], store = (ctx ??= context(element)).store ??= {};
|
|
38
|
+
if (store[name] === undefined) {
|
|
39
|
+
store[name] = (element.getAttribute(name) || '').trim();
|
|
39
40
|
}
|
|
41
|
+
let current = value ? (delimiter + value) : '';
|
|
40
42
|
if (id === null) {
|
|
41
|
-
|
|
42
|
-
store[base] += (store[base] ? delimiter : '') + value;
|
|
43
|
-
}
|
|
43
|
+
store[name] += current;
|
|
44
44
|
}
|
|
45
45
|
else {
|
|
46
|
-
let
|
|
47
|
-
if (
|
|
48
|
-
|
|
49
|
-
for (let i = 0, n = parts.length; i < n; i++) {
|
|
50
|
-
part = parts[i].trim();
|
|
51
|
-
if (part === '') {
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
dynamic[part] = null;
|
|
55
|
-
hot[part] = null;
|
|
56
|
-
}
|
|
46
|
+
let previous = store[id];
|
|
47
|
+
if (!previous) {
|
|
48
|
+
store[name] += current;
|
|
57
49
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
for (let part in cold) {
|
|
61
|
-
if (part in hot) {
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
delete dynamic[part];
|
|
65
|
-
}
|
|
50
|
+
else if (previous !== current) {
|
|
51
|
+
store[name] = store[name].replace(previous, current);
|
|
66
52
|
}
|
|
67
|
-
store[id] =
|
|
53
|
+
store[id] = current;
|
|
68
54
|
}
|
|
69
|
-
|
|
70
|
-
for (let key in dynamic) {
|
|
71
|
-
value += (value ? delimiter : '') + key;
|
|
72
|
-
}
|
|
73
|
-
schedule(ctx, element, name, state, value);
|
|
55
|
+
schedule(ctx, element, name, state, store[name]);
|
|
74
56
|
}
|
|
75
|
-
function property(ctx, element, id, name,
|
|
57
|
+
function property(ctx, element, id, name, state, value) {
|
|
76
58
|
if (value == null || value === false || value === '') {
|
|
77
59
|
value = '';
|
|
78
60
|
}
|
|
@@ -132,14 +114,14 @@ const set = (element, name, value, state = STATE_HYDRATING) => {
|
|
|
132
114
|
effect(() => {
|
|
133
115
|
let v = value(element);
|
|
134
116
|
if (v == null || typeof v !== 'object') {
|
|
135
|
-
fn(ctx, element, id, name,
|
|
117
|
+
fn(ctx, element, id, name, state, v);
|
|
136
118
|
}
|
|
137
119
|
else if (isArray(v)) {
|
|
138
120
|
let last = v.length - 1;
|
|
139
121
|
for (let i = 0, n = v.length; i < n; i++) {
|
|
140
|
-
fn(ctx, element, id, name,
|
|
122
|
+
fn(ctx, element, id, name, state === STATE_HYDRATING
|
|
141
123
|
? state
|
|
142
|
-
: i !== last ? STATE_WAITING : state);
|
|
124
|
+
: i !== last ? STATE_WAITING : state, v[i]);
|
|
143
125
|
}
|
|
144
126
|
}
|
|
145
127
|
});
|
|
@@ -147,7 +129,7 @@ const set = (element, name, value, state = STATE_HYDRATING) => {
|
|
|
147
129
|
return;
|
|
148
130
|
}
|
|
149
131
|
if (type !== 'object') {
|
|
150
|
-
fn(null, element, null, name,
|
|
132
|
+
fn(null, element, null, name, state, value);
|
|
151
133
|
return;
|
|
152
134
|
}
|
|
153
135
|
if (isArray(value)) {
|
|
@@ -160,7 +142,7 @@ const set = (element, name, value, state = STATE_HYDRATING) => {
|
|
|
160
142
|
}
|
|
161
143
|
return;
|
|
162
144
|
}
|
|
163
|
-
fn(null, element, null, name,
|
|
145
|
+
fn(null, element, null, name, state, value);
|
|
164
146
|
};
|
|
165
147
|
const spread = function (element, value) {
|
|
166
148
|
if (isObject(value)) {
|
package/package.json
CHANGED
package/src/attributes.ts
CHANGED
|
@@ -54,72 +54,43 @@ function list(
|
|
|
54
54
|
element: Element,
|
|
55
55
|
id: null | number,
|
|
56
56
|
name: string,
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
state: State,
|
|
58
|
+
value: unknown
|
|
59
59
|
) {
|
|
60
60
|
if (value == null || value === false || value === '') {
|
|
61
61
|
value = '';
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
dynamic = store[name] as Attributes | undefined,
|
|
68
|
-
type = typeof value;
|
|
64
|
+
if (id === null && (!value || typeof value !== 'string')) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
69
67
|
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
let delimiter = delimiters[name],
|
|
69
|
+
store = (ctx ??= context(element)).store ??= {};
|
|
72
70
|
|
|
73
|
-
|
|
74
|
-
store[name] =
|
|
71
|
+
if (store[name] === undefined) {
|
|
72
|
+
store[name] = (element.getAttribute(name) || '').trim();
|
|
75
73
|
}
|
|
76
74
|
|
|
75
|
+
let current = value ? (delimiter + value) : '';
|
|
76
|
+
|
|
77
77
|
if (id === null) {
|
|
78
|
-
|
|
79
|
-
store[base] += (store[base] ? delimiter : '') + value;
|
|
80
|
-
}
|
|
78
|
+
store[name] += current;
|
|
81
79
|
}
|
|
82
80
|
else {
|
|
83
|
-
let
|
|
84
|
-
|
|
85
|
-
if (value && type === 'string') {
|
|
86
|
-
let part: string,
|
|
87
|
-
parts = (value as string).split(delimiter);
|
|
81
|
+
let previous = store[id] as string | undefined;
|
|
88
82
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (part === '') {
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
dynamic[part] = null;
|
|
97
|
-
hot[part] = null;
|
|
98
|
-
}
|
|
83
|
+
if (!previous) {
|
|
84
|
+
store[name] += current;
|
|
99
85
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (cold !== undefined) {
|
|
104
|
-
for (let part in cold) {
|
|
105
|
-
if (part in hot) {
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
delete dynamic[part];
|
|
110
|
-
}
|
|
86
|
+
else if (previous !== current) {
|
|
87
|
+
store[name] = (store[name] as string).replace(previous, current);
|
|
111
88
|
}
|
|
112
89
|
|
|
113
|
-
store[id] =
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
value = store[base];
|
|
117
|
-
|
|
118
|
-
for (let key in dynamic) {
|
|
119
|
-
value += (value ? delimiter : '') + key;
|
|
90
|
+
store[id] = current;
|
|
120
91
|
}
|
|
121
92
|
|
|
122
|
-
schedule(ctx, element, name, state,
|
|
93
|
+
schedule(ctx, element, name, state, store[name]);
|
|
123
94
|
}
|
|
124
95
|
|
|
125
96
|
function property(
|
|
@@ -127,8 +98,8 @@ function property(
|
|
|
127
98
|
element: Element,
|
|
128
99
|
id: null | number,
|
|
129
100
|
name: string,
|
|
130
|
-
|
|
131
|
-
|
|
101
|
+
state: State,
|
|
102
|
+
value: unknown
|
|
132
103
|
) {
|
|
133
104
|
if (value == null || value === false || value === '') {
|
|
134
105
|
value = '';
|
|
@@ -213,7 +184,7 @@ const set = (element: Element, name: string, value: unknown, state: State = STAT
|
|
|
213
184
|
let v = (value as Function)(element);
|
|
214
185
|
|
|
215
186
|
if (v == null || typeof v !== 'object') {
|
|
216
|
-
fn(ctx, element, id, name,
|
|
187
|
+
fn(ctx, element, id, name, state, v);
|
|
217
188
|
}
|
|
218
189
|
else if (isArray(v)) {
|
|
219
190
|
let last = v.length - 1;
|
|
@@ -224,10 +195,10 @@ const set = (element: Element, name: string, value: unknown, state: State = STAT
|
|
|
224
195
|
element,
|
|
225
196
|
id,
|
|
226
197
|
name,
|
|
227
|
-
v[i],
|
|
228
198
|
state === STATE_HYDRATING
|
|
229
199
|
? state
|
|
230
|
-
: i !== last ? STATE_WAITING : state
|
|
200
|
+
: i !== last ? STATE_WAITING : state,
|
|
201
|
+
v[i],
|
|
231
202
|
);
|
|
232
203
|
}
|
|
233
204
|
}
|
|
@@ -239,7 +210,7 @@ const set = (element: Element, name: string, value: unknown, state: State = STAT
|
|
|
239
210
|
}
|
|
240
211
|
|
|
241
212
|
if (type !== 'object') {
|
|
242
|
-
fn(null, element, null, name,
|
|
213
|
+
fn(null, element, null, name, state, value);
|
|
243
214
|
return;
|
|
244
215
|
}
|
|
245
216
|
|
|
@@ -256,7 +227,7 @@ const set = (element: Element, name: string, value: unknown, state: State = STAT
|
|
|
256
227
|
return;
|
|
257
228
|
}
|
|
258
229
|
|
|
259
|
-
fn(null, element, null, name,
|
|
230
|
+
fn(null, element, null, name, state, value);
|
|
260
231
|
};
|
|
261
232
|
|
|
262
233
|
const spread = function (element: Element, value: Attributes | Attributes[]) {
|
package/src/slot/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ import render from './render';
|
|
|
5
5
|
|
|
6
6
|
export default (anchor: Element, value: unknown): void => {
|
|
7
7
|
if (typeof value === 'function') {
|
|
8
|
-
effect(anchor, value as
|
|
8
|
+
effect(anchor, value as Parameters<typeof effect>[1]);
|
|
9
9
|
}
|
|
10
10
|
else {
|
|
11
11
|
anchor.after( render(anchor, value) );
|