dfish-widget 1.0.74 → 1.0.75

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/lib/index.esm.js CHANGED
@@ -5682,18 +5682,25 @@ const props = __props;
5682
5682
  return item
5683
5683
  };
5684
5684
 
5685
- const merge = (newList, oldList) => {
5686
- if (!Array.isArray(newList)) return
5687
- const item = newList.find(n => n[propChildren] && n[propChildren].length);
5688
- if (item) {
5689
- if (!oldList) oldList = props.children;
5690
- const old = oldList.find(n => n[propValue] == item[propValue]);
5691
- if (old) {
5692
- if (old[propChildren] && old[propChildren].length) {
5693
- merge(item[propChildren], old[propChildren]);
5694
- } else {
5695
- old[propChildren] = item[propChildren];
5696
- toFlat(old[propChildren], old);
5685
+ const merge = (newList) => {
5686
+ if (!Array.isArray(newList)) return []
5687
+ const oldList = JSON.parse(JSON.stringify(props.children));
5688
+ mergeChildren(newList, oldList);
5689
+ props.children.length = 0;
5690
+ props.children.push.apply(props.children, newList);
5691
+ flatList.value = toFlat(newList);
5692
+ };
5693
+
5694
+ const mergeChildren = (newList, oldList) => {
5695
+ for (let n of newList) {
5696
+ let o = oldList.find(v => v[propValue] === n[propValue]);
5697
+ if (o) {
5698
+ if (o[propChildren]) {
5699
+ if (n[propChildren]) mergeChildren(n[propChildren], o[propChildren]);
5700
+ else n[propChildren] = o[propChildren];
5701
+ }
5702
+ if (o.expanded != null) {
5703
+ n.expanded = o.expanded;
5697
5704
  }
5698
5705
  }
5699
5706
  }
@@ -6700,18 +6707,25 @@ const props = __props;
6700
6707
  return item
6701
6708
  };
6702
6709
 
6703
- const merge = (newList, oldList) => {
6704
- if (!Array.isArray(newList)) return
6705
- const item = newList.find(n => n[propChildren] && n[propChildren].length);
6706
- if (item) {
6707
- if (!oldList) oldList = props.children;
6708
- const old = oldList.find(n => n[propValue] == item[propValue]);
6709
- if (old) {
6710
- if (old[propChildren] && old[propChildren].length) {
6711
- merge(item[propChildren], old[propChildren]);
6712
- } else {
6713
- old[propChildren] = item[propChildren];
6714
- toFlat(old[propChildren], old);
6710
+ const merge = (newList) => {
6711
+ if (!Array.isArray(newList)) return []
6712
+ const oldList = JSON.parse(JSON.stringify(props.children));
6713
+ mergeChildren(newList, oldList);
6714
+ props.children.length = 0;
6715
+ props.children.push.apply(props.children, newList);
6716
+ flatList.value = toFlat(newList);
6717
+ };
6718
+
6719
+ const mergeChildren = (newList, oldList) => {
6720
+ for (let n of newList) {
6721
+ let o = oldList.find(v => v[propValue] === n[propValue]);
6722
+ if (o) {
6723
+ if (o[propChildren]) {
6724
+ if (n[propChildren]) mergeChildren(n[propChildren], o[propChildren]);
6725
+ else n[propChildren] = o[propChildren];
6726
+ }
6727
+ if (o.expanded != null) {
6728
+ n.expanded = o.expanded;
6715
6729
  }
6716
6730
  }
6717
6731
  }