@lvce-editor/virtual-dom 1.8.0 → 1.9.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/dist/index.d.ts +5 -0
- package/dist/index.js +16 -9
- package/package.json +1 -1
- package/src/parts/AddPatch/AddPatch.ts +0 -1
- package/src/parts/ApplyPatch/ApplyPatch.ts +4 -1
- package/src/parts/NavigateParentPatch/NavigateParentPatch.ts +0 -1
- package/src/parts/PatchFunctions/PatchFunctions.ts +4 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
// src/parts/PatchType/PatchType.ts
|
|
2
|
-
var SetText = 1;
|
|
3
|
-
var SetAttribute = 3;
|
|
4
|
-
var RemoveAttribute = 4;
|
|
5
|
-
var Add = 6;
|
|
6
|
-
var NavigateChild = 7;
|
|
7
|
-
var RemoveChild = 9;
|
|
8
|
-
var NavigateSibling = 10;
|
|
9
|
-
|
|
10
1
|
// src/parts/ElementTags/ElementTags.ts
|
|
11
2
|
var Audio = "audio";
|
|
12
3
|
var Button = "button";
|
|
@@ -481,6 +472,9 @@ var setText = ($Element, value) => {
|
|
|
481
472
|
$Element.nodeValue = value;
|
|
482
473
|
};
|
|
483
474
|
var removeChild = ($Element, index) => {
|
|
475
|
+
console.log("el", $Element.className);
|
|
476
|
+
console.log("index", index);
|
|
477
|
+
console.log("ch", $Element.children.length);
|
|
484
478
|
const $Child = $Element.children[index];
|
|
485
479
|
$Child.remove();
|
|
486
480
|
};
|
|
@@ -488,6 +482,16 @@ var add = ($Element, nodes) => {
|
|
|
488
482
|
renderInternal2($Element, nodes, {}, {});
|
|
489
483
|
};
|
|
490
484
|
|
|
485
|
+
// src/parts/PatchType/PatchType.ts
|
|
486
|
+
var SetText = 1;
|
|
487
|
+
var SetAttribute = 3;
|
|
488
|
+
var RemoveAttribute = 4;
|
|
489
|
+
var Add = 6;
|
|
490
|
+
var NavigateChild = 7;
|
|
491
|
+
var NavigateParent = 8;
|
|
492
|
+
var RemoveChild = 9;
|
|
493
|
+
var NavigateSibling = 10;
|
|
494
|
+
|
|
491
495
|
// src/parts/ApplyPatch/ApplyPatch.ts
|
|
492
496
|
var applyPatch = ($Element, patches) => {
|
|
493
497
|
let $Current = $Element;
|
|
@@ -518,6 +522,9 @@ var applyPatch = ($Element, patches) => {
|
|
|
518
522
|
case NavigateChild:
|
|
519
523
|
$Current = $Current.childNodes[patch.index];
|
|
520
524
|
break;
|
|
525
|
+
case NavigateParent:
|
|
526
|
+
$Current = $Current.parentNode;
|
|
527
|
+
break;
|
|
521
528
|
default:
|
|
522
529
|
break;
|
|
523
530
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Patch } from '../Patch/Patch.ts'
|
|
2
|
-
import * as PatchType from '../PatchType/PatchType.ts'
|
|
3
2
|
import * as PatchFunctions from '../PatchFunctions/PatchFunctions.ts'
|
|
3
|
+
import * as PatchType from '../PatchType/PatchType.ts'
|
|
4
4
|
|
|
5
5
|
export const applyPatch = ($Element: Node, patches: readonly Patch[]): void => {
|
|
6
6
|
let $Current = $Element
|
|
@@ -31,6 +31,9 @@ export const applyPatch = ($Element: Node, patches: readonly Patch[]): void => {
|
|
|
31
31
|
case PatchType.NavigateChild:
|
|
32
32
|
$Current = ($Current as HTMLElement).childNodes[patch.index]
|
|
33
33
|
break
|
|
34
|
+
case PatchType.NavigateParent:
|
|
35
|
+
$Current = $Current.parentNode as HTMLElement
|
|
36
|
+
break
|
|
34
37
|
default:
|
|
35
38
|
break
|
|
36
39
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { VirtualDomNode } from '../VirtualDomNode/VirtualDomNode.ts'
|
|
2
1
|
import * as RenderInternal from '../RenderInternal/RenderInternal.ts'
|
|
2
|
+
import { VirtualDomNode } from '../VirtualDomNode/VirtualDomNode.ts'
|
|
3
3
|
|
|
4
4
|
export const setAttribute = (
|
|
5
5
|
$Element: HTMLElement,
|
|
@@ -18,6 +18,9 @@ export const setText = ($Element: Text, value: string): void => {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export const removeChild = ($Element: HTMLElement, index: number): void => {
|
|
21
|
+
console.log('el', $Element.className)
|
|
22
|
+
console.log('index', index)
|
|
23
|
+
console.log('ch', $Element.children.length)
|
|
21
24
|
const $Child = $Element.children[index]
|
|
22
25
|
$Child.remove()
|
|
23
26
|
}
|