Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.2.43: initial value of watcher changed from undefined to an empty array #7074

Closed
cexbrayat opened this issue Nov 9, 2022 · 0 comments · Fixed by #7075
Closed

v3.2.43: initial value of watcher changed from undefined to an empty array #7074

cexbrayat opened this issue Nov 9, 2022 · 0 comments · Fixed by #7075
Labels
p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. regression

Comments

@cexbrayat
Copy link
Member

Vue version

3.2.43

Link to minimal reproduction

https://sfc.vuejs.org/#eNp9UV1vnDAQ/Csrq1KIBLht+nTlUPLWH9C3ulIo7N25wR+yF04R4r9nMVx0SaQ84d2dnZkdJvHgfTkOKHaiIjS+bwhrZQGqoU9ffvUaxuLgwl6J9tTYI4K2QI6a/peO5MKzEvU0wTab50r2euWQiaSSV8xcxjZoTxCRBg89LzExRSZRVhvvAgGTOeMHwi6HgE1LesTldcjh3FB7ghkOwRm4Yec3PxfS1tlIqynYv25n2S3sa/j29ZZBV5DNNyOZs3oIoXmuIgVtj3Wd/fm7oJNOtlyxcqS9cmz6AfPUtXj+vfRycH2XXgk3raFdy6xbpR/iKXtMyC2rbr3iy3RhmHmPywv1/Lg4AZiT4gTaGOw057gDCgNHrewCqOSaKOcncrFGWJjGl/+js/xjkyW1DTjn3cWkEpzfUitxIvJxJ+Vg/dOx5PzkPc9kGCxpg0XnzP1d+b38cSc7Puq6X2I0xb/gzhEDKyqRzG7kkpsjhiKg7TBg+FTsHfaN4LvZB9EUk7KzmF8AXV35QQ==

Steps to reproduce

const total = computed(() => 10);
const totalHistory = ref<Array<string>>([]);
watch(
  () => total.value,
  (newTotal, oldTotal) => {
    totalHistory.value.push(`Total changed from ${oldTotal} to ${newTotal}`);
  },
  { immediate: true }
);

This used to log Total changed from undefined to 10 but now logs Total changed from to 10 as oldTotal is now an empty array.

Change the version to v3.2.42 to this the former behavior

What is expected?

The initial value should be undefined (or a breaking change should be added to the changelog to mention that it is now an empty array)

What is actually happening?

The initial value is an empty array

System Info

System:
    OS: macOS 12.6
    CPU: (10) arm64 Apple M1 Max
    Memory: 21.55 GB / 64.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.17.0 - ~/.volta/tools/image/node/16.17.0/bin/node
    Yarn: 1.22.17 - ~/.volta/tools/image/yarn/1.22.17/bin/yarn
    npm: 8.19.2 - ~/.volta/tools/image/npm/8.19.2/bin/npm
  Browsers:
    Chrome: 107.0.5304.87
    Firefox: 106.0.5
    Safari: 16.0
  npmPackages:
    vue: 3.2.43 => 3.2.43

Any additional comments?

No response

LinusBorg added a commit that referenced this issue Nov 9, 2022
@LinusBorg LinusBorg added regression p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. labels Nov 9, 2022
yyx990803 pushed a commit that referenced this issue Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. regression
Projects
None yet
2 participants