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

When accessing the hasOwnProperty method of the array, the key cannot be tracked #10455

Closed
catpigdog opened this issue Mar 4, 2024 · 5 comments

Comments

@catpigdog
Copy link

Vue version

3.3.6

Link to minimal reproduction

https://play.vuejs.org/#eNp9kVFrwjAQx7/KkZdVKFXn2IOosA0ftocpc29GRomnrWuTkFyrIv3uu7boZAwfAsn9/3f53d1JPFkblQWKoRh55VJL4JEKO5E6za1xBCdwGCtKSwxhH5NKFketppsNKoIKNs7kcMcF7qSWWhntCWLn4iOML3nBsh/CfQiDVUfqPyWCoAPjCZykBqizTYZRZrZBUyNKYj/b67kzFh0dg16HC1R8pF5jhoTtV8veSupRt8VncH4Q5jaLCfkFMEr6E0JPoy5faueVKkJBnj/epNto543mOTQsUiiT2zRDN7OUMpgUw5ay1uIsM/u3JkauwPAcVwmq73/iO3+oY1LMHXp0JUpx0Sh2W6RWni7e8cD3i5ibdZGx+4b4gTy0omZsbc+FXjP2la+hfW22mertp58eCLU/N1WD1s6q8UvBu3y50fov7iB6aPJ4JTzFrxJdXZMHOIgG0aOofgANZsmX

Steps to reproduce

const array = reactive([1, 2, 3])
watchSyncEffect(() => {
console.log(array.hasOwnProperty(0))
})
delete array[0]

What is expected?

The side effect function should be executed twice
// true
// false

What is actually happening?

The side effect function was only executed once
// true

System Info

No response

Any additional comments?

No response

@Shyam-Chen
Copy link
Contributor

Shyam-Chen commented Mar 5, 2024

+ delete array[0]
watchSyncEffect(() => {
  console.log(array.hasOwnProperty(0))
})
- delete array[0]

Or

- watchSyncEffect
+ watchPostEffect

@LinusBorg
Copy link
Member

that's not a solution to the issue ...

@catpigdog
Copy link
Author

@LinusBorg Do you also think this is a bug?

@LinusBorg
Copy link
Member

Probably, yes.

@catpigdog
Copy link
Author

const array = reactive([1, 2, 3])
watchSyncEffect(() => {
console.log(array.hasOwnProperty(0))
})
array[0] = 11

The above example will not trigger the effect.
I looked at the source code due to a bug caused by incorrect collection of key name types of number.
But now this issue has been fixed.😁

@github-actions github-actions bot locked and limited conversation to collaborators Apr 30, 2024
lynxlangya pushed a commit to lynxlangya/core that referenced this issue May 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants