selectic 3.0.9 → 3.0.10

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.
@@ -47,6 +47,9 @@ function deepClone(obj, refs = new WeakMap()) {
47
47
  return refs.get(obj);
48
48
  }
49
49
  if (typeof obj === 'object') {
50
+ if (obj === null) {
51
+ return obj;
52
+ }
50
53
  if (Array.isArray(obj)) {
51
54
  const ref = [];
52
55
  refs.set(obj, ref);
@@ -288,10 +291,10 @@ class SelecticStore {
288
291
  this.setAutomaticClose();
289
292
  this.commit('isOpen', false);
290
293
  };
291
- const value = this.props.value;
294
+ const value = deepClone(this.props.value);
292
295
  /* set initial value for non reactive attribute */
293
296
  this.cacheRequest = new Map();
294
- const stateParam = Object.assign({}, this.props.params);
297
+ const stateParam = deepClone(this.props.params);
295
298
  if (stateParam.optionBehavior) {
296
299
  this.buildOptionBehavior(stateParam.optionBehavior, stateParam);
297
300
  delete stateParam.optionBehavior;
@@ -681,7 +684,7 @@ class SelecticStore {
681
684
  }
682
685
  /* This method is for the computed property listOptions */
683
686
  getListOptions() {
684
- const options = this.props.options;
687
+ const options = deepClone(this.props.options);
685
688
  const listOptions = [];
686
689
  if (!Array.isArray(options)) {
687
690
  return listOptions;
@@ -718,7 +721,7 @@ class SelecticStore {
718
721
  }
719
722
  /* This method is for the computed property elementOptions */
720
723
  getElementOptions() {
721
- const options = this.props.childOptions;
724
+ const options = deepClone(this.props.childOptions);
722
725
  const childOptions = [];
723
726
  if (!Array.isArray(options) || options.length === 0) {
724
727
  return childOptions;
@@ -43,6 +43,9 @@ function deepClone(obj, refs = new WeakMap()) {
43
43
  return refs.get(obj);
44
44
  }
45
45
  if (typeof obj === 'object') {
46
+ if (obj === null) {
47
+ return obj;
48
+ }
46
49
  if (Array.isArray(obj)) {
47
50
  const ref = [];
48
51
  refs.set(obj, ref);
@@ -284,10 +287,10 @@ class SelecticStore {
284
287
  this.setAutomaticClose();
285
288
  this.commit('isOpen', false);
286
289
  };
287
- const value = this.props.value;
290
+ const value = deepClone(this.props.value);
288
291
  /* set initial value for non reactive attribute */
289
292
  this.cacheRequest = new Map();
290
- const stateParam = Object.assign({}, this.props.params);
293
+ const stateParam = deepClone(this.props.params);
291
294
  if (stateParam.optionBehavior) {
292
295
  this.buildOptionBehavior(stateParam.optionBehavior, stateParam);
293
296
  delete stateParam.optionBehavior;
@@ -677,7 +680,7 @@ class SelecticStore {
677
680
  }
678
681
  /* This method is for the computed property listOptions */
679
682
  getListOptions() {
680
- const options = this.props.options;
683
+ const options = deepClone(this.props.options);
681
684
  const listOptions = [];
682
685
  if (!Array.isArray(options)) {
683
686
  return listOptions;
@@ -714,7 +717,7 @@ class SelecticStore {
714
717
  }
715
718
  /* This method is for the computed property elementOptions */
716
719
  getElementOptions() {
717
- const options = this.props.childOptions;
720
+ const options = deepClone(this.props.childOptions);
718
721
  const childOptions = [];
719
722
  if (!Array.isArray(options) || options.length === 0) {
720
723
  return childOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "selectic",
3
- "version": "3.0.9",
3
+ "version": "3.0.10",
4
4
  "description": "Smart Select for VueJS 3.x",
5
5
  "main": "dist/selectic.common.js",
6
6
  "module": "dist/selectic.esm.js",
package/src/Store.tsx CHANGED
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  import { reactive, watch, unref, computed, ComputedRef } from 'vue';
8
- import { convertToRegExp, assignObject } from './tools';
8
+ import { convertToRegExp, assignObject, deepClone } from './tools';
9
9
 
10
10
  /* {{{ Types definitions */
11
11
 
@@ -587,13 +587,13 @@ export default class SelecticStore {
587
587
  this.commit('isOpen', false);
588
588
  }
589
589
 
590
- const value = this.props.value;
590
+ const value = deepClone(this.props.value);
591
591
 
592
592
  /* set initial value for non reactive attribute */
593
593
  this.cacheRequest = new Map();
594
594
 
595
595
  const stateParam: SelecticStoreStateParams | SelecticStoreState =
596
- Object.assign({}, this.props.params);
596
+ deepClone(this.props.params);
597
597
 
598
598
  if (stateParam.optionBehavior) {
599
599
  this.buildOptionBehavior(
@@ -1060,7 +1060,7 @@ export default class SelecticStore {
1060
1060
 
1061
1061
  /* This method is for the computed property listOptions */
1062
1062
  private getListOptions(): OptionValue[] {
1063
- const options = this.props.options;
1063
+ const options = deepClone(this.props.options);
1064
1064
  const listOptions: OptionValue[] = [];
1065
1065
 
1066
1066
  if (!Array.isArray(options)) {
@@ -1106,7 +1106,7 @@ export default class SelecticStore {
1106
1106
 
1107
1107
  /* This method is for the computed property elementOptions */
1108
1108
  private getElementOptions(): OptionValue[] {
1109
- const options = this.props.childOptions;
1109
+ const options = deepClone(this.props.childOptions);
1110
1110
  const childOptions: OptionValue[] = [];
1111
1111
 
1112
1112
  if (!Array.isArray(options) || options.length === 0) {
package/src/tools.ts CHANGED
@@ -12,6 +12,10 @@ export function deepClone<T = any>(obj: T, refs: WeakMap<any, any> = new WeakMap
12
12
  }
13
13
 
14
14
  if (typeof obj === 'object') {
15
+ if (obj === null) {
16
+ return obj;
17
+ }
18
+
15
19
  if (Array.isArray(obj)) {
16
20
  const ref: any[] = [];
17
21
  refs.set(obj, ref);