@esportsplus/template 0.22.3 → 0.22.5

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,18 +31,19 @@ const ondisconnect = (element, fn) => {
31
31
  (element[CLEANUP] ??= []).push(fn);
32
32
  };
33
33
  const remove = (groups) => {
34
- let group, head, tail;
34
+ let group;
35
35
  while (group = groups.pop()) {
36
- head = group.head;
37
- tail = group.tail || head;
38
- for (let node = tail; node; node = previousSibling.call(node)) {
39
- if (CLEANUP in node) {
40
- cleanup.add(node[CLEANUP]);
36
+ let head = group.head, next, tail = group.tail || head;
37
+ while (tail) {
38
+ if (CLEANUP in tail) {
39
+ cleanup.add(tail[CLEANUP]);
41
40
  }
42
- node.remove();
43
- if (head === node) {
41
+ next = previousSibling.call(tail);
42
+ tail.remove();
43
+ if (head === tail) {
44
44
  break;
45
45
  }
46
+ tail = next;
46
47
  }
47
48
  }
48
49
  if (!scheduled && cleanup.length) {
@@ -13,20 +13,23 @@ function update(anchor, value) {
13
13
  if (value == null || value === false) {
14
14
  value = '';
15
15
  }
16
+ let textnode = this.textnode;
16
17
  if (typeof value !== 'object') {
17
- let textnode = this.textnode;
18
18
  if (textnode) {
19
19
  nodeValue.call(textnode, String(value));
20
+ if (!textnode.isConnected) {
21
+ anchor.after(textnode);
22
+ }
20
23
  }
21
24
  else {
22
- textnode = this.textnode = text(String(value));
23
- }
24
- if (!textnode.isConnected) {
25
- anchor.after(textnode);
25
+ anchor.after(this.textnode = text(String(value)));
26
26
  }
27
27
  }
28
28
  else {
29
29
  let fragment = render(anchor, value), head = firstChild.call(fragment);
30
+ if (textnode && textnode.isConnected) {
31
+ remove([{ head: textnode, tail: textnode }]);
32
+ }
30
33
  if (head) {
31
34
  this.group = {
32
35
  head,
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "private": false,
15
15
  "type": "module",
16
16
  "types": "./build/index.d.ts",
17
- "version": "0.22.3",
17
+ "version": "0.22.5",
18
18
  "scripts": {
19
19
  "build": "tsc && tsc-alias",
20
20
  "-": "-"
@@ -45,22 +45,26 @@ const ondisconnect = (element: Element, fn: VoidFunction) => {
45
45
  };
46
46
 
47
47
  const remove = (groups: SlotGroup[]) => {
48
- let group, head, tail;
48
+ let group;
49
49
 
50
50
  while (group = groups.pop()) {
51
- head = group.head;
52
- tail = group.tail || head;
51
+ let head = group.head,
52
+ next,
53
+ tail = group.tail || head;
53
54
 
54
- for (let node = tail; node; node = previousSibling.call(node)) {
55
- if (CLEANUP in node) {
56
- cleanup.add( node[CLEANUP] as VoidFunction[] );
55
+ while (tail) {
56
+ if (CLEANUP in tail) {
57
+ cleanup.add( tail[CLEANUP] as VoidFunction[] );
57
58
  }
58
59
 
59
- node.remove();
60
+ next = previousSibling.call(tail);
61
+ tail.remove();
60
62
 
61
- if (head === node) {
63
+ if (head === tail) {
62
64
  break;
63
65
  }
66
+
67
+ tail = next;
64
68
  }
65
69
  }
66
70
 
@@ -18,24 +18,28 @@ function update(this: { group?: SlotGroup, textnode?: Node }, anchor: Element, v
18
18
  value = '';
19
19
  }
20
20
 
21
- if (typeof value !== 'object') {
22
- let textnode = this.textnode;
21
+ let textnode = this.textnode;
23
22
 
23
+ if (typeof value !== 'object') {
24
24
  if (textnode) {
25
25
  nodeValue.call(textnode, String(value));
26
+
27
+ if (!textnode.isConnected) {
28
+ anchor.after(textnode);
29
+ }
26
30
  }
27
31
  else {
28
- textnode = this.textnode = text( String(value) );
29
- }
30
-
31
- if (!textnode.isConnected) {
32
- anchor.after(textnode);
32
+ anchor.after( this.textnode = text( String(value) ) );
33
33
  }
34
34
  }
35
35
  else {
36
36
  let fragment = render(anchor, value),
37
37
  head = firstChild.call(fragment);
38
38
 
39
+ if (textnode && textnode.isConnected) {
40
+ remove([{ head: textnode as Element, tail: textnode as Element }]);
41
+ }
42
+
39
43
  if (head) {
40
44
  this.group = {
41
45
  head,