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

test(watch): watching a reactive array #10848

Merged
merged 1 commit into from
May 3, 2024

Conversation

skirtles-code
Copy link
Contributor

These tests were inspired by the changes in #9417. I don't think the changes proposed there can be merged as they would break backwards compatibility, but I found it interesting that they didn't cause the existing tests to fail.

It seems we have relatively few tests for watch(reactiveArray, ...), and in particular how it differs from watch(plainArray, ...). I experimented locally and found I was able to introduce various bugs without triggering any test failures.

Here I've aimed to test 3 ways that reactive arrays behave differently from plain arrays when passed as a source to watch:

  1. If the reactive array contains a function, it should not be invoked.
  2. If the reactive array contains a ref, it should not be unwrapped in the newValue or oldValue passed to the callback.
  3. A reactive array should be deep: true by default.
  4. A reactive array with an explicit deep: false should be watched one level deep, starting from the array itself.

Copy link

github-actions bot commented May 1, 2024

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 90.7 kB 34.5 kB 31.1 kB
vue.global.prod.js 148 kB 53.7 kB 48 kB

Usages

Name Size Gzip Brotli
createApp 50.8 kB 19.9 kB 18.1 kB
createSSRApp 54.1 kB 21.2 kB 19.3 kB
defineCustomElement 53.1 kB 20.6 kB 18.8 kB
overall 64.5 kB 24.9 kB 22.5 kB

@yyx990803 yyx990803 merged commit c0c9432 into vuejs:main May 3, 2024
11 checks passed
yangmingshan added a commit to vue-mini/vue-mini that referenced this pull request May 7, 2024
wangdaoo pushed a commit to wangdaoo/core that referenced this pull request May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants