@lvce-editor/virtual-dom 5.1.0 → 6.0.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 CHANGED
@@ -37,8 +37,7 @@ export interface RemovePatch {
37
37
  readonly type: 5;
38
38
  }
39
39
  export interface ReplacePatch {
40
- readonly index: number;
41
- readonly node: VirtualDomNode;
40
+ readonly nodes: readonly VirtualDomNode[];
42
41
  readonly type: 2;
43
42
  }
44
43
  export interface TextPatch {
@@ -75,5 +74,14 @@ export declare const renderInto: ($Parent: any, dom: any, eventMap?: {}) => void
75
74
  * @returns
76
75
  */
77
76
  export declare const render: (elements: any, eventMap?: {}, newEventMap?: {}) => HTMLElement;
77
+ declare const A: number, Abbr: number, Article: number, Aside: number, Audio$1: number, Br: number, Button: number, Cite: number, Code: number, Col: number, ColGroup: number, Data: number, Dd: number, Del: number, Div: number, Dl: number, Dt: number, Figcaption: number, Figure: number, Footer: number, H1: number, H2: number, H3: number, H4: number, H5: number, H6: number, Header: number, Hr: number, I: number, Img: number, Input: number, Ins: number, Kbd: number, Label: number, Li: number, Nav: number, Ol: number, Option$1: number, P: number, Pre: number, Root: number, Search: number, Section: number, Select: number, Span: number, Table: number, TBody: number, Td: number, Text$1: number, TextArea: number, Tfoot: number, Th: number, THead: number, Time: number, Tr: number, Ul: number, Video: number;
78
+
79
+ declare namespace VirtualDomElements {
80
+ export { A, Abbr, Article, Aside, Audio$1 as Audio, Br, Button, Cite, Code, Col, ColGroup, Data, Dd, Del, Div, Dl, Dt, Figcaption, Figure, Footer, H1, H2, H3, H4, H5, H6, Header, Hr, I, Img, Input, Ins, Kbd, Label, Li, Nav, Ol, Option$1 as Option, P, Pre, Root, Search, Section, Select, Span, TBody, THead, Table, Td, Text$1 as Text, TextArea, Tfoot, Th, Time, Tr, Ul, Video };
81
+ }
82
+
83
+ export {
84
+ VirtualDomElements,
85
+ };
78
86
 
79
87
  export {};
package/dist/index.js CHANGED
@@ -1,287 +1,287 @@
1
- const Audio$1 = 'audio';
2
- const Button$1 = 'button';
3
- const Col$1 = 'col';
4
- const ColGroup$1 = 'colgroup';
5
- const Del$1 = 'del';
6
- const Div$1 = 'div';
7
- const H1$1 = 'h1';
8
- const H2$1 = 'h2';
9
- const H3$1 = 'h3';
10
- const H4$1 = 'h4';
11
- const H5$1 = 'h5';
12
- const H6$1 = 'h6';
13
- const I$1 = 'i';
14
- const Img$1 = 'img';
15
- const Input$1 = 'input';
16
- const Ins$1 = 'ins';
17
- const Kbd$1 = 'kbd';
18
- const Span$1 = 'span';
19
- const Table$1 = 'table';
20
- const TBody$1 = 'tbody';
21
- const Td$1 = 'td';
22
- const Th$1 = 'th';
23
- const THead$1 = 'thead';
24
- const Tr$1 = 'tr';
25
- const Article$1 = 'article';
26
- const Aside$1 = 'aside';
27
- const Footer$1 = 'footer';
28
- const Header$1 = 'header';
29
- const Nav$1 = 'nav';
30
- const Section$1 = 'section';
31
- const Search$1 = 'search';
32
- const Dd$1 = 'dd';
33
- const Dl$1 = 'dl';
34
- const Figcaption$1 = 'figcaption';
35
- const Figure$1 = 'figure';
36
- const Hr$1 = 'hr';
37
- const Li$1 = 'li';
38
- const Ol$1 = 'ol';
39
- const P$1 = 'p';
40
- const Pre$1 = 'pre';
41
- const A$1 = 'a';
42
- const Br$1 = 'br';
43
- const Cite$1 = 'cite';
44
- const Data$1 = 'data';
45
- const Time$1 = 'time';
46
- const Tfoot$1 = 'tfoot';
47
- const Ul$1 = 'ul';
48
- const Video$1 = 'video';
49
- const TextArea$1 = 'textarea';
50
- const Select$1 = 'select';
51
- const Option$1 = 'option';
52
- const Code$1 = 'code';
53
- const Label$1 = 'label';
54
- const Dt$1 = 'dt';
1
+ const Audio$2 = 'audio';
2
+ const Button$2 = 'button';
3
+ const Col$2 = 'col';
4
+ const ColGroup$2 = 'colgroup';
5
+ const Del$2 = 'del';
6
+ const Div$2 = 'div';
7
+ const H1$2 = 'h1';
8
+ const H2$2 = 'h2';
9
+ const H3$2 = 'h3';
10
+ const H4$2 = 'h4';
11
+ const H5$2 = 'h5';
12
+ const H6$2 = 'h6';
13
+ const I$2 = 'i';
14
+ const Img$2 = 'img';
15
+ const Input$2 = 'input';
16
+ const Ins$2 = 'ins';
17
+ const Kbd$2 = 'kbd';
18
+ const Span$2 = 'span';
19
+ const Table$2 = 'table';
20
+ const TBody$2 = 'tbody';
21
+ const Td$2 = 'td';
22
+ const Th$2 = 'th';
23
+ const THead$2 = 'thead';
24
+ const Tr$2 = 'tr';
25
+ const Article$2 = 'article';
26
+ const Aside$2 = 'aside';
27
+ const Footer$2 = 'footer';
28
+ const Header$2 = 'header';
29
+ const Nav$2 = 'nav';
30
+ const Section$2 = 'section';
31
+ const Search$2 = 'search';
32
+ const Dd$2 = 'dd';
33
+ const Dl$2 = 'dl';
34
+ const Figcaption$2 = 'figcaption';
35
+ const Figure$2 = 'figure';
36
+ const Hr$2 = 'hr';
37
+ const Li$2 = 'li';
38
+ const Ol$2 = 'ol';
39
+ const P$2 = 'p';
40
+ const Pre$2 = 'pre';
41
+ const A$2 = 'a';
42
+ const Br$2 = 'br';
43
+ const Cite$2 = 'cite';
44
+ const Data$2 = 'data';
45
+ const Time$2 = 'time';
46
+ const Tfoot$2 = 'tfoot';
47
+ const Ul$2 = 'ul';
48
+ const Video$2 = 'video';
49
+ const TextArea$2 = 'textarea';
50
+ const Select$2 = 'select';
51
+ const Option$2 = 'option';
52
+ const Code$2 = 'code';
53
+ const Label$2 = 'label';
54
+ const Dt$2 = 'dt';
55
55
 
56
- const Audio = 0;
57
- const Button = 1;
58
- const Col = 2;
59
- const ColGroup = 3;
60
- const Div = 4;
61
- const H1 = 5;
62
- const Input = 6;
63
- const Kbd = 7;
64
- const Span = 8;
65
- const Table = 9;
66
- const TBody = 10;
67
- const Td = 11;
56
+ const Audio$1 = 0;
57
+ const Button$1 = 1;
58
+ const Col$1 = 2;
59
+ const ColGroup$1 = 3;
60
+ const Div$1 = 4;
61
+ const H1$1 = 5;
62
+ const Input$1 = 6;
63
+ const Kbd$1 = 7;
64
+ const Span$1 = 8;
65
+ const Table$1 = 9;
66
+ const TBody$1 = 10;
67
+ const Td$1 = 11;
68
68
  const Text$1 = 12;
69
- const Th = 13;
70
- const THead = 14;
71
- const Tr = 15;
72
- const I = 16;
73
- const Img = 17;
74
- const Root = 0;
75
- const Ins = 20;
76
- const Del = 21;
77
- const H2 = 22;
78
- const H3 = 23;
79
- const H4 = 24;
80
- const H5 = 25;
81
- const H6 = 26;
82
- const Article = 27;
83
- const Aside = 28;
84
- const Footer = 29;
85
- const Header = 30;
86
- const Nav = 40;
87
- const Section = 41;
88
- const Search = 42;
89
- const Dd = 43;
90
- const Dl = 44;
91
- const Figcaption = 45;
92
- const Figure = 46;
93
- const Hr = 47;
94
- const Li = 48;
95
- const Ol = 49;
96
- const P = 50;
97
- const Pre = 51;
98
- const A = 53;
99
- const Abbr = 54;
100
- const Br = 55;
101
- const Cite = 56;
102
- const Data = 57;
103
- const Time = 58;
104
- const Tfoot = 59;
105
- const Ul = 60;
106
- const Video = 61;
107
- const TextArea = 62;
108
- const Select = 63;
109
- const Option = 64;
110
- const Code = 65;
111
- const Label = 66;
112
- const Dt = 67;
69
+ const Th$1 = 13;
70
+ const THead$1 = 14;
71
+ const Tr$1 = 15;
72
+ const I$1 = 16;
73
+ const Img$1 = 17;
74
+ const Root$1 = 0;
75
+ const Ins$1 = 20;
76
+ const Del$1 = 21;
77
+ const H2$1 = 22;
78
+ const H3$1 = 23;
79
+ const H4$1 = 24;
80
+ const H5$1 = 25;
81
+ const H6$1 = 26;
82
+ const Article$1 = 27;
83
+ const Aside$1 = 28;
84
+ const Footer$1 = 29;
85
+ const Header$1 = 30;
86
+ const Nav$1 = 40;
87
+ const Section$1 = 41;
88
+ const Search$1 = 42;
89
+ const Dd$1 = 43;
90
+ const Dl$1 = 44;
91
+ const Figcaption$1 = 45;
92
+ const Figure$1 = 46;
93
+ const Hr$1 = 47;
94
+ const Li$1 = 48;
95
+ const Ol$1 = 49;
96
+ const P$1 = 50;
97
+ const Pre$1 = 51;
98
+ const A$1 = 53;
99
+ const Abbr$1 = 54;
100
+ const Br$1 = 55;
101
+ const Cite$1 = 56;
102
+ const Data$1 = 57;
103
+ const Time$1 = 58;
104
+ const Tfoot$1 = 59;
105
+ const Ul$1 = 60;
106
+ const Video$1 = 61;
107
+ const TextArea$1 = 62;
108
+ const Select$1 = 63;
109
+ const Option$1 = 64;
110
+ const Code$1 = 65;
111
+ const Label$1 = 66;
112
+ const Dt$1 = 67;
113
113
 
114
- const VirtualDomElements = {
114
+ const VirtualDomElements$1 = {
115
115
  __proto__: null,
116
- A,
117
- Abbr,
118
- Article,
119
- Aside,
120
- Audio,
121
- Br,
122
- Button,
123
- Cite,
124
- Code,
125
- Col,
126
- ColGroup,
127
- Data,
128
- Dd,
129
- Del,
130
- Div,
131
- Dl,
132
- Dt,
133
- Figcaption,
134
- Figure,
135
- Footer,
136
- H1,
137
- H2,
138
- H3,
139
- H4,
140
- H5,
141
- H6,
142
- Header,
143
- Hr,
144
- I,
145
- Img,
146
- Input,
147
- Ins,
148
- Kbd,
149
- Label,
150
- Li,
151
- Nav,
152
- Ol,
153
- Option,
154
- P,
155
- Pre,
156
- Root,
157
- Search,
158
- Section,
159
- Select,
160
- Span,
161
- TBody,
162
- THead,
163
- Table,
164
- Td,
116
+ A: A$1,
117
+ Abbr: Abbr$1,
118
+ Article: Article$1,
119
+ Aside: Aside$1,
120
+ Audio: Audio$1,
121
+ Br: Br$1,
122
+ Button: Button$1,
123
+ Cite: Cite$1,
124
+ Code: Code$1,
125
+ Col: Col$1,
126
+ ColGroup: ColGroup$1,
127
+ Data: Data$1,
128
+ Dd: Dd$1,
129
+ Del: Del$1,
130
+ Div: Div$1,
131
+ Dl: Dl$1,
132
+ Dt: Dt$1,
133
+ Figcaption: Figcaption$1,
134
+ Figure: Figure$1,
135
+ Footer: Footer$1,
136
+ H1: H1$1,
137
+ H2: H2$1,
138
+ H3: H3$1,
139
+ H4: H4$1,
140
+ H5: H5$1,
141
+ H6: H6$1,
142
+ Header: Header$1,
143
+ Hr: Hr$1,
144
+ I: I$1,
145
+ Img: Img$1,
146
+ Input: Input$1,
147
+ Ins: Ins$1,
148
+ Kbd: Kbd$1,
149
+ Label: Label$1,
150
+ Li: Li$1,
151
+ Nav: Nav$1,
152
+ Ol: Ol$1,
153
+ Option: Option$1,
154
+ P: P$1,
155
+ Pre: Pre$1,
156
+ Root: Root$1,
157
+ Search: Search$1,
158
+ Section: Section$1,
159
+ Select: Select$1,
160
+ Span: Span$1,
161
+ TBody: TBody$1,
162
+ THead: THead$1,
163
+ Table: Table$1,
164
+ Td: Td$1,
165
165
  Text: Text$1,
166
- TextArea,
167
- Tfoot,
168
- Th,
169
- Time,
170
- Tr,
171
- Ul,
172
- Video
166
+ TextArea: TextArea$1,
167
+ Tfoot: Tfoot$1,
168
+ Th: Th$1,
169
+ Time: Time$1,
170
+ Tr: Tr$1,
171
+ Ul: Ul$1,
172
+ Video: Video$1
173
173
  };
174
174
 
175
175
  const getElementTag$1 = type => {
176
176
  switch (type) {
177
- case A:
178
- return A$1;
179
- case Article:
180
- return Article$1;
181
- case Aside:
182
- return Aside$1;
183
- case Audio:
184
- return Audio$1;
185
- case Br:
186
- return Br$1;
187
- case Button:
188
- return Button$1;
189
- case Cite:
190
- return Cite$1;
191
- case Code:
192
- return Code$1;
193
- case Col:
194
- return Col$1;
195
- case ColGroup:
196
- return ColGroup$1;
197
- case Data:
198
- return Data$1;
199
- case Dd:
200
- return Dd$1;
201
- case Del:
202
- return Del$1;
203
- case Div:
204
- return Div$1;
205
- case Dl:
206
- return Dl$1;
207
- case Dt:
208
- return Dt$1;
209
- case Figcaption:
210
- return Figcaption$1;
211
- case Figure:
212
- return Figure$1;
213
- case Footer:
214
- return Footer$1;
215
- case H1:
216
- return H1$1;
217
- case H2:
218
- return H2$1;
219
- case H3:
220
- return H3$1;
221
- case H4:
222
- return H4$1;
223
- case H5:
224
- return H5$1;
225
- case H6:
226
- return H6$1;
227
- case Header:
228
- return Header$1;
229
- case Hr:
230
- return Hr$1;
231
- case I:
232
- return I$1;
233
- case Img:
234
- return Img$1;
235
- case Input:
236
- return Input$1;
237
- case Ins:
238
- return Ins$1;
239
- case Kbd:
240
- return Kbd$1;
241
- case Label:
242
- return Label$1;
243
- case Li:
244
- return Li$1;
245
- case Nav:
246
- return Nav$1;
247
- case Ol:
248
- return Ol$1;
249
- case Option:
250
- return Option$1;
251
- case P:
252
- return P$1;
253
- case Pre:
254
- return Pre$1;
255
- case Search:
256
- return Search$1;
257
- case Section:
258
- return Section$1;
259
- case Select:
260
- return Select$1;
261
- case Span:
262
- return Span$1;
263
- case Table:
264
- return Table$1;
265
- case TBody:
266
- return TBody$1;
267
- case Td:
268
- return Td$1;
269
- case TextArea:
270
- return TextArea$1;
271
- case Tfoot:
272
- return Tfoot$1;
273
- case Th:
274
- return Th$1;
275
- case THead:
276
- return THead$1;
277
- case Time:
278
- return Time$1;
279
- case Tr:
280
- return Tr$1;
281
- case Ul:
282
- return Ul$1;
283
- case Video:
284
- return Video$1;
177
+ case A$1:
178
+ return A$2;
179
+ case Article$1:
180
+ return Article$2;
181
+ case Aside$1:
182
+ return Aside$2;
183
+ case Audio$1:
184
+ return Audio$2;
185
+ case Br$1:
186
+ return Br$2;
187
+ case Button$1:
188
+ return Button$2;
189
+ case Cite$1:
190
+ return Cite$2;
191
+ case Code$1:
192
+ return Code$2;
193
+ case Col$1:
194
+ return Col$2;
195
+ case ColGroup$1:
196
+ return ColGroup$2;
197
+ case Data$1:
198
+ return Data$2;
199
+ case Dd$1:
200
+ return Dd$2;
201
+ case Del$1:
202
+ return Del$2;
203
+ case Div$1:
204
+ return Div$2;
205
+ case Dl$1:
206
+ return Dl$2;
207
+ case Dt$1:
208
+ return Dt$2;
209
+ case Figcaption$1:
210
+ return Figcaption$2;
211
+ case Figure$1:
212
+ return Figure$2;
213
+ case Footer$1:
214
+ return Footer$2;
215
+ case H1$1:
216
+ return H1$2;
217
+ case H2$1:
218
+ return H2$2;
219
+ case H3$1:
220
+ return H3$2;
221
+ case H4$1:
222
+ return H4$2;
223
+ case H5$1:
224
+ return H5$2;
225
+ case H6$1:
226
+ return H6$2;
227
+ case Header$1:
228
+ return Header$2;
229
+ case Hr$1:
230
+ return Hr$2;
231
+ case I$1:
232
+ return I$2;
233
+ case Img$1:
234
+ return Img$2;
235
+ case Input$1:
236
+ return Input$2;
237
+ case Ins$1:
238
+ return Ins$2;
239
+ case Kbd$1:
240
+ return Kbd$2;
241
+ case Label$1:
242
+ return Label$2;
243
+ case Li$1:
244
+ return Li$2;
245
+ case Nav$1:
246
+ return Nav$2;
247
+ case Ol$1:
248
+ return Ol$2;
249
+ case Option$1:
250
+ return Option$2;
251
+ case P$1:
252
+ return P$2;
253
+ case Pre$1:
254
+ return Pre$2;
255
+ case Search$1:
256
+ return Search$2;
257
+ case Section$1:
258
+ return Section$2;
259
+ case Select$1:
260
+ return Select$2;
261
+ case Span$1:
262
+ return Span$2;
263
+ case Table$1:
264
+ return Table$2;
265
+ case TBody$1:
266
+ return TBody$2;
267
+ case Td$1:
268
+ return Td$2;
269
+ case TextArea$1:
270
+ return TextArea$2;
271
+ case Tfoot$1:
272
+ return Tfoot$2;
273
+ case Th$1:
274
+ return Th$2;
275
+ case THead$1:
276
+ return THead$2;
277
+ case Time$1:
278
+ return Time$2;
279
+ case Tr$1:
280
+ return Tr$2;
281
+ case Ul$1:
282
+ return Ul$2;
283
+ case Video$1:
284
+ return Video$2;
285
285
  default:
286
286
  throw new Error(`element tag not found ${type}`);
287
287
  }
@@ -528,7 +528,125 @@ const setProps = ($Element, props, eventMap, newEventMap) => {
528
528
  };
529
529
 
530
530
  const {
531
- Text} = VirtualDomElements;
531
+ A,
532
+ Abbr,
533
+ Article,
534
+ Aside,
535
+ Audio,
536
+ Br,
537
+ Button,
538
+ Cite,
539
+ Code,
540
+ Col,
541
+ ColGroup,
542
+ Data,
543
+ Dd,
544
+ Del,
545
+ Div,
546
+ Dl,
547
+ Dt,
548
+ Figcaption,
549
+ Figure,
550
+ Footer,
551
+ H1,
552
+ H2,
553
+ H3,
554
+ H4,
555
+ H5,
556
+ H6,
557
+ Header,
558
+ Hr,
559
+ I,
560
+ Img,
561
+ Input,
562
+ Ins,
563
+ Kbd,
564
+ Label,
565
+ Li,
566
+ Nav,
567
+ Ol,
568
+ Option,
569
+ P,
570
+ Pre,
571
+ Root,
572
+ Search,
573
+ Section,
574
+ Select,
575
+ Span,
576
+ Table,
577
+ TBody,
578
+ Td,
579
+ Text,
580
+ TextArea,
581
+ Tfoot,
582
+ Th,
583
+ THead,
584
+ Time,
585
+ Tr,
586
+ Ul,
587
+ Video
588
+ } = VirtualDomElements$1;
589
+
590
+ const VirtualDomElements = {
591
+ __proto__: null,
592
+ A,
593
+ Abbr,
594
+ Article,
595
+ Aside,
596
+ Audio,
597
+ Br,
598
+ Button,
599
+ Cite,
600
+ Code,
601
+ Col,
602
+ ColGroup,
603
+ Data,
604
+ Dd,
605
+ Del,
606
+ Div,
607
+ Dl,
608
+ Dt,
609
+ Figcaption,
610
+ Figure,
611
+ Footer,
612
+ H1,
613
+ H2,
614
+ H3,
615
+ H4,
616
+ H5,
617
+ H6,
618
+ Header,
619
+ Hr,
620
+ I,
621
+ Img,
622
+ Input,
623
+ Ins,
624
+ Kbd,
625
+ Label,
626
+ Li,
627
+ Nav,
628
+ Ol,
629
+ Option,
630
+ P,
631
+ Pre,
632
+ Root,
633
+ Search,
634
+ Section,
635
+ Select,
636
+ Span,
637
+ TBody,
638
+ THead,
639
+ Table,
640
+ Td,
641
+ Text,
642
+ TextArea,
643
+ Tfoot,
644
+ Th,
645
+ Time,
646
+ Tr,
647
+ Ul,
648
+ Video
649
+ };
532
650
 
533
651
  const renderDomTextNode = element => {
534
652
  return document.createTextNode(element.text);
@@ -564,11 +682,60 @@ const renderInternal = ($Parent, elements, eventMap, newEventMap) => {
564
682
  $Parent.append(...stack);
565
683
  };
566
684
 
685
+ // Map of property names to attribute names for cases where they differ
686
+ const propertyToAttribute = {
687
+ className: 'class',
688
+ htmlFor: 'for',
689
+ ariaActivedescendant: 'aria-activedescendant',
690
+ ariaControls: 'aria-controls',
691
+ ariaLabelledBy: 'aria-labelledby',
692
+ ariaOwns: 'aria-owns',
693
+ inputType: 'type'
694
+ };
695
+
696
+ // Style properties that need to be set on element.style
697
+ const styleProperties = new Set(['width', 'height', 'top', 'left', 'marginTop', 'paddingLeft', 'paddingRight']);
698
+
699
+ // TODO merge this with the setProp function
700
+
567
701
  const setAttribute = ($Element, key, value) => {
568
- $Element.setAttribute(key, value);
702
+ // Handle width/height for images (set as attributes, not style)
703
+ if ((key === 'width' || key === 'height') && $Element instanceof HTMLImageElement) {
704
+ // @ts-ignore - dynamic property access
705
+ $Element[key] = value;
706
+ return;
707
+ }
708
+
709
+ // Handle style properties
710
+ if (styleProperties.has(key)) {
711
+ // @ts-ignore - dynamic style property access
712
+ $Element.style[key] = typeof value === 'number' ? `${value}px` : value;
713
+ return;
714
+ }
715
+
716
+ // Handle aria attributes - map camelCase to hyphenated form
717
+ if (key in propertyToAttribute) {
718
+ $Element.setAttribute(propertyToAttribute[key], value);
719
+ return;
720
+ }
721
+
722
+ // Use property assignment for known DOM properties, attribute for others
723
+ if (key in $Element) {
724
+ // @ts-ignore - dynamic property access
725
+ $Element[key] = value;
726
+ } else {
727
+ $Element.setAttribute(key, value);
728
+ }
569
729
  };
570
730
  const removeAttribute = ($Element, key) => {
571
- $Element.removeAttribute(key);
731
+ // Handle style properties
732
+ if (styleProperties.has(key)) {
733
+ // @ts-ignore - dynamic style property access
734
+ $Element.style[key] = '';
735
+ return;
736
+ }
737
+ const attributeName = propertyToAttribute[key] || key;
738
+ $Element.removeAttribute(attributeName);
572
739
  };
573
740
  const setText = ($Element, value) => {
574
741
  $Element.nodeValue = value;
@@ -580,8 +747,18 @@ const removeChild = ($Element, index) => {
580
747
  const add$1 = ($Element, nodes) => {
581
748
  renderInternal($Element, nodes, {}, {});
582
749
  };
750
+ const replace = ($Element, nodes) => {
751
+ // Create a temporary container to render the new nodes
752
+ const $Temp = document.createElement('div');
753
+ renderInternal($Temp, nodes, {}, {});
754
+ // Replace the current element with the new ones
755
+ const $NewElement = $Temp.firstElementChild;
756
+ $Element.replaceWith($NewElement);
757
+ return $NewElement;
758
+ };
583
759
 
584
760
  const SetText = 1;
761
+ const Replace = 2;
585
762
  const SetAttribute = 3;
586
763
  const RemoveAttribute = 4;
587
764
  const Add = 6;
@@ -612,6 +789,9 @@ const applyPatch = ($Element, patches) => {
612
789
  case RemoveChild:
613
790
  removeChild($Current, patch.index);
614
791
  break;
792
+ case Replace:
793
+ $Current = replace($Current, patch.nodes);
794
+ break;
615
795
  case SetAttribute:
616
796
  setAttribute($Current, patch.key, patch.value);
617
797
  break;
@@ -1024,4 +1204,4 @@ const rememberFocus = ($Viewlet, dom, eventMap, uid = 0) => {
1024
1204
  return $Viewlet;
1025
1205
  };
1026
1206
 
1027
- export { addFileHandle, applyPatch, getComponentUid, getComponentUidFromEvent, getDragInfo, getFileHandles, registerEventListeners, rememberFocus, removeDragInfo, render, renderInto, setComponentUid, setDragInfo, setIpc };
1207
+ export { VirtualDomElements, addFileHandle, applyPatch, getComponentUid, getComponentUidFromEvent, getDragInfo, getFileHandles, registerEventListeners, rememberFocus, removeDragInfo, render, renderInto, setComponentUid, setDragInfo, setIpc };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/virtual-dom",
3
- "version": "5.1.0",
3
+ "version": "6.0.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/lvce-editor/virtual-dom.git"