@varlet/use 3.2.2 → 3.2.3

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.cjs CHANGED
@@ -459,15 +459,23 @@ function useVModel(props, key, options = {}) {
459
459
  });
460
460
  }
461
461
  const proxy = (0, import_vue11.ref)(getValue());
462
+ let shouldEmit = true;
462
463
  (0, import_vue11.watch)(
463
464
  () => props[key],
464
465
  () => {
466
+ shouldEmit = false;
465
467
  proxy.value = getValue();
468
+ (0, import_vue11.nextTick)(() => {
469
+ shouldEmit = true;
470
+ });
466
471
  }
467
472
  );
468
473
  (0, import_vue11.watch)(
469
474
  () => proxy.value,
470
475
  (newValue) => {
476
+ if (!shouldEmit) {
477
+ return;
478
+ }
471
479
  emit ? emit(event, newValue) : (0, import_shared7.call)(props[event], newValue);
472
480
  }
473
481
  );
package/lib/index.js CHANGED
@@ -418,7 +418,7 @@ function useWindowSize(options = {}) {
418
418
 
419
419
  // src/useVModel.ts
420
420
  import { call } from "@varlet/shared";
421
- import { computed as computed3, ref as ref5, watch as watch3 } from "vue";
421
+ import { computed as computed3, nextTick as nextTick3, ref as ref5, watch as watch3 } from "vue";
422
422
  function useVModel(props, key, options = {}) {
423
423
  const { passive = true, eventName, defaultValue, emit } = options;
424
424
  const event = eventName != null ? eventName : `onUpdate:${key.toString()}`;
@@ -437,15 +437,23 @@ function useVModel(props, key, options = {}) {
437
437
  });
438
438
  }
439
439
  const proxy = ref5(getValue());
440
+ let shouldEmit = true;
440
441
  watch3(
441
442
  () => props[key],
442
443
  () => {
444
+ shouldEmit = false;
443
445
  proxy.value = getValue();
446
+ nextTick3(() => {
447
+ shouldEmit = true;
448
+ });
444
449
  }
445
450
  );
446
451
  watch3(
447
452
  () => proxy.value,
448
453
  (newValue) => {
454
+ if (!shouldEmit) {
455
+ return;
456
+ }
449
457
  emit ? emit(event, newValue) : call(props[event], newValue);
450
458
  }
451
459
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/use",
3
- "version": "3.2.2",
3
+ "version": "3.2.3",
4
4
  "type": "module",
5
5
  "main": "lib/index.cjs",
6
6
  "module": "lib/index.js",
@@ -33,7 +33,7 @@
33
33
  "url": "https://github.com/varletjs/varlet/issues"
34
34
  },
35
35
  "dependencies": {
36
- "@varlet/shared": "3.2.2"
36
+ "@varlet/shared": "3.2.3"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/node": "^18.7.18",