@lvce-editor/virtual-dom 1.8.0 → 1.10.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 +17 -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/ElementTagMap/ElementTagMap.ts +2 -0
- package/src/parts/ElementTags/ElementTags.ts +1 -0
- package/src/parts/NavigateParentPatch/NavigateParentPatch.ts +0 -1
- package/src/parts/PatchFunctions/PatchFunctions.ts +1 -1
- package/src/parts/RemoveAttributePatch/RemoveAttributePatch.ts +0 -1
- package/src/parts/VirtualDomElements/VirtualDomElements.ts +1 -0
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";
|
|
@@ -59,6 +50,7 @@ var Video = "video";
|
|
|
59
50
|
var TextArea = "textarea";
|
|
60
51
|
var Select = "select";
|
|
61
52
|
var Option = "option";
|
|
53
|
+
var Code = "code";
|
|
62
54
|
|
|
63
55
|
// src/parts/VirtualDomElements/VirtualDomElements.ts
|
|
64
56
|
var Audio2 = 0;
|
|
@@ -113,6 +105,7 @@ var Video2 = 61;
|
|
|
113
105
|
var TextArea2 = 62;
|
|
114
106
|
var Select2 = 63;
|
|
115
107
|
var Option2 = 64;
|
|
108
|
+
var Code2 = 65;
|
|
116
109
|
|
|
117
110
|
// src/parts/ElementTagMap/ElementTagMap.ts
|
|
118
111
|
var getElementTag = (type) => {
|
|
@@ -219,6 +212,8 @@ var getElementTag = (type) => {
|
|
|
219
212
|
return Select;
|
|
220
213
|
case Option2:
|
|
221
214
|
return Option;
|
|
215
|
+
case Code2:
|
|
216
|
+
return Code;
|
|
222
217
|
default:
|
|
223
218
|
throw new Error(`element tag not found ${type}`);
|
|
224
219
|
}
|
|
@@ -488,6 +483,16 @@ var add = ($Element, nodes) => {
|
|
|
488
483
|
renderInternal2($Element, nodes, {}, {});
|
|
489
484
|
};
|
|
490
485
|
|
|
486
|
+
// src/parts/PatchType/PatchType.ts
|
|
487
|
+
var SetText = 1;
|
|
488
|
+
var SetAttribute = 3;
|
|
489
|
+
var RemoveAttribute = 4;
|
|
490
|
+
var Add = 6;
|
|
491
|
+
var NavigateChild = 7;
|
|
492
|
+
var NavigateParent = 8;
|
|
493
|
+
var RemoveChild = 9;
|
|
494
|
+
var NavigateSibling = 10;
|
|
495
|
+
|
|
491
496
|
// src/parts/ApplyPatch/ApplyPatch.ts
|
|
492
497
|
var applyPatch = ($Element, patches) => {
|
|
493
498
|
let $Current = $Element;
|
|
@@ -518,6 +523,9 @@ var applyPatch = ($Element, patches) => {
|
|
|
518
523
|
case NavigateChild:
|
|
519
524
|
$Current = $Current.childNodes[patch.index];
|
|
520
525
|
break;
|
|
526
|
+
case NavigateParent:
|
|
527
|
+
$Current = $Current.parentNode;
|
|
528
|
+
break;
|
|
521
529
|
default:
|
|
522
530
|
break;
|
|
523
531
|
}
|
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
|
}
|
|
@@ -105,6 +105,8 @@ export const getElementTag = (type) => {
|
|
|
105
105
|
return ElementTag.Select
|
|
106
106
|
case VirtualDomElements.Option:
|
|
107
107
|
return ElementTag.Option
|
|
108
|
+
case VirtualDomElements.Code:
|
|
109
|
+
return ElementTag.Code
|
|
108
110
|
default:
|
|
109
111
|
throw new Error(`element tag not found ${type}`)
|
|
110
112
|
}
|
|
@@ -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,
|