@esportsplus/template 0.26.2 → 0.26.3

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.
@@ -31,20 +31,20 @@ function list(ctx, element, id, name, state, value) {
31
31
  if (value == null || value === false || value === '') {
32
32
  value = '';
33
33
  }
34
- let base = name + '.static', delimiter = delimiters[name], store = (ctx ??= context(element)).store ??= {}, dynamic = store[name], type = typeof value;
34
+ let base = name + '.static', delimiter = delimiters[name], store = (ctx ??= context(element)).store ??= {}, dynamic = store[name];
35
35
  if (dynamic === undefined) {
36
36
  let value = (element.getAttribute(name) || '').trim();
37
37
  store[base] = value;
38
38
  store[name] = dynamic = new Set();
39
39
  }
40
40
  if (id === null) {
41
- if (value && type === 'string') {
41
+ if (value && typeof value === 'string') {
42
42
  store[base] += (store[base] ? delimiter : '') + value;
43
43
  }
44
44
  }
45
45
  else {
46
46
  let hot = {};
47
- if (value && type === 'string') {
47
+ if (value && typeof value === 'string') {
48
48
  let part, parts = value.split(delimiter);
49
49
  for (let i = 0, n = parts.length; i < n; i++) {
50
50
  part = parts[i].trim();
@@ -126,8 +126,8 @@ function task() {
126
126
  }
127
127
  }
128
128
  const set = (element, name, value) => {
129
- let fn = name === 'class' || name === 'style' ? list : property, state = STATE_HYDRATING, type = typeof value;
130
- if (type === 'function') {
129
+ let fn = name === 'class' || name === 'style' ? list : property, state = STATE_HYDRATING;
130
+ if (typeof value === 'function') {
131
131
  if (name.startsWith('on')) {
132
132
  return event(element, name, value);
133
133
  }
@@ -151,7 +151,7 @@ const set = (element, name, value) => {
151
151
  state = STATE_NONE;
152
152
  return;
153
153
  }
154
- if (type !== 'object') {
154
+ if (typeof value !== 'object') {
155
155
  }
156
156
  else if (isArray(value)) {
157
157
  for (let i = 0, n = value.length; i < n; i++) {
@@ -40,14 +40,17 @@ class EffectSlot {
40
40
  }
41
41
  }
42
42
  update(value) {
43
- if (this.group) {
44
- remove(this.group);
43
+ if (typeof value === 'function') {
44
+ return this.update(value());
45
+ }
46
+ let { anchor, group, textnode } = this;
47
+ if (group) {
48
+ remove(group);
45
49
  this.group = null;
46
50
  }
47
51
  if (value == null || value === false) {
48
52
  value = '';
49
53
  }
50
- let { anchor, textnode } = this;
51
54
  if (typeof value !== 'object') {
52
55
  if (textnode) {
53
56
  nodeValue.call(textnode, String(value));
package/package.json CHANGED
@@ -2,9 +2,9 @@
2
2
  "author": "ICJR",
3
3
  "dependencies": {
4
4
  "@esportsplus/queue": "^0.1.0",
5
- "@esportsplus/reactivity": "^0.18.0",
6
- "@esportsplus/tasks": "^0.2.1",
7
- "@esportsplus/utilities": "^0.22.2"
5
+ "@esportsplus/reactivity": "^0.18.1",
6
+ "@esportsplus/tasks": "^0.4.0",
7
+ "@esportsplus/utilities": "^0.25.0"
8
8
  },
9
9
  "devDependencies": {
10
10
  "@esportsplus/typescript": "^0.9.2"
@@ -14,7 +14,7 @@
14
14
  "private": false,
15
15
  "type": "module",
16
16
  "types": "./build/index.d.ts",
17
- "version": "0.26.2",
17
+ "version": "0.26.3",
18
18
  "scripts": {
19
19
  "build": "tsc && tsc-alias",
20
20
  "-": "-"
package/src/attributes.ts CHANGED
@@ -64,8 +64,7 @@ function list(
64
64
  let base = name + '.static',
65
65
  delimiter = delimiters[name],
66
66
  store = (ctx ??= context(element)).store ??= {},
67
- dynamic = store[name] as Set<string> | undefined,
68
- type = typeof value;
67
+ dynamic = store[name] as Set<string> | undefined;
69
68
 
70
69
  if (dynamic === undefined) {
71
70
  let value = (element.getAttribute(name) || '').trim();
@@ -75,14 +74,14 @@ function list(
75
74
  }
76
75
 
77
76
  if (id === null) {
78
- if (value && type === 'string') {
77
+ if (value && typeof value === 'string') {
79
78
  store[base] += (store[base] ? delimiter : '') + value;
80
79
  }
81
80
  }
82
81
  else {
83
82
  let hot: Attributes = {};
84
83
 
85
- if (value && type === 'string') {
84
+ if (value && typeof value === 'string') {
86
85
  let part: string,
87
86
  parts = (value as string).split(delimiter);
88
87
 
@@ -200,10 +199,9 @@ function task() {
200
199
 
201
200
  const set = (element: Element, name: string, value: unknown) => {
202
201
  let fn = name === 'class' || name === 'style' ? list : property,
203
- state: State = STATE_HYDRATING,
204
- type = typeof value;
202
+ state: State = STATE_HYDRATING;
205
203
 
206
- if (type === 'function') {
204
+ if (typeof value === 'function') {
207
205
  if (name.startsWith('on')) {
208
206
  return event(element, name as `on${string}`, value as Function);
209
207
  }
@@ -243,7 +241,7 @@ const set = (element: Element, name: string, value: unknown) => {
243
241
  return;
244
242
  }
245
243
 
246
- if (type !== 'object') {
244
+ if (typeof value !== 'object') {
247
245
  // Skip isArray when possible
248
246
  }
249
247
  else if (isArray(value)) {
@@ -53,9 +53,15 @@ class EffectSlot {
53
53
  }
54
54
  }
55
55
 
56
- update(value: unknown) {
57
- if (this.group) {
58
- remove(this.group);
56
+ update(value: unknown): void {
57
+ if (typeof value === 'function') {
58
+ return this.update( value() );
59
+ }
60
+
61
+ let { anchor, group, textnode } = this;
62
+
63
+ if (group) {
64
+ remove(group);
59
65
  this.group = null;
60
66
  }
61
67
 
@@ -63,8 +69,6 @@ class EffectSlot {
63
69
  value = '';
64
70
  }
65
71
 
66
- let { anchor, textnode } = this;
67
-
68
72
  if (typeof value !== 'object') {
69
73
  if (textnode) {
70
74
  nodeValue.call(textnode, String(value));