@lvce-editor/virtual-dom 6.0.0 → 6.1.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 +1 -1
- package/dist/index.js +7 -7
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export interface TextPatch {
|
|
|
45
45
|
readonly value: string;
|
|
46
46
|
}
|
|
47
47
|
export type Patch = TextPatch | AttributePatch | ReplacePatch | RemoveAttributePatch | RemovePatch | AddPatch | NavigateChildPatch | NavigateParentPatch | RemoveChildPatch | NavigateSiblingPatch;
|
|
48
|
-
export declare const applyPatch: ($Element: Node, patches: readonly Patch[]) => void;
|
|
48
|
+
export declare const applyPatch: ($Element: Node, patches: readonly Patch[], eventMap?: Record<string, any>) => void;
|
|
49
49
|
export declare const setComponentUid: ($Element: any, uid: any) => void;
|
|
50
50
|
export declare const getComponentUid: ($Element: any) => number;
|
|
51
51
|
export declare const getComponentUidFromEvent: (event: any) => number;
|
package/dist/index.js
CHANGED
|
@@ -744,13 +744,13 @@ const removeChild = ($Element, index) => {
|
|
|
744
744
|
const $Child = $Element.children[index];
|
|
745
745
|
$Child.remove();
|
|
746
746
|
};
|
|
747
|
-
const add$1 = ($Element, nodes) => {
|
|
748
|
-
renderInternal($Element, nodes,
|
|
747
|
+
const add$1 = ($Element, nodes, eventMap = {}) => {
|
|
748
|
+
renderInternal($Element, nodes, eventMap, eventMap);
|
|
749
749
|
};
|
|
750
|
-
const replace = ($Element, nodes) => {
|
|
750
|
+
const replace = ($Element, nodes, eventMap = {}) => {
|
|
751
751
|
// Create a temporary container to render the new nodes
|
|
752
752
|
const $Temp = document.createElement('div');
|
|
753
|
-
renderInternal($Temp, nodes,
|
|
753
|
+
renderInternal($Temp, nodes, eventMap, eventMap);
|
|
754
754
|
// Replace the current element with the new ones
|
|
755
755
|
const $NewElement = $Temp.firstElementChild;
|
|
756
756
|
$Element.replaceWith($NewElement);
|
|
@@ -767,12 +767,12 @@ const NavigateParent = 8;
|
|
|
767
767
|
const RemoveChild = 9;
|
|
768
768
|
const NavigateSibling = 10;
|
|
769
769
|
|
|
770
|
-
const applyPatch = ($Element, patches) => {
|
|
770
|
+
const applyPatch = ($Element, patches, eventMap = {}) => {
|
|
771
771
|
let $Current = $Element;
|
|
772
772
|
for (const patch of patches) {
|
|
773
773
|
switch (patch.type) {
|
|
774
774
|
case Add:
|
|
775
|
-
add$1($Current, patch.nodes);
|
|
775
|
+
add$1($Current, patch.nodes, eventMap);
|
|
776
776
|
break;
|
|
777
777
|
case NavigateChild:
|
|
778
778
|
$Current = $Current.childNodes[patch.index];
|
|
@@ -790,7 +790,7 @@ const applyPatch = ($Element, patches) => {
|
|
|
790
790
|
removeChild($Current, patch.index);
|
|
791
791
|
break;
|
|
792
792
|
case Replace:
|
|
793
|
-
$Current = replace($Current, patch.nodes);
|
|
793
|
+
$Current = replace($Current, patch.nodes, eventMap);
|
|
794
794
|
break;
|
|
795
795
|
case SetAttribute:
|
|
796
796
|
setAttribute($Current, patch.key, patch.value);
|