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

fix(reactivity): ensure readonly on plain arrays doesn't track array methods. (close: #2493) #2506

Merged
merged 1 commit into from
Nov 27, 2020

Conversation

LinusBorg
Copy link
Member

@LinusBorg LinusBorg commented Oct 28, 2020

When using readonly() on a plain array, accessing the array in any way should not result in any tracking, no deps should be collected, as a plain array can't be tracked anyway.

However, for array methods like includes, we currently use arrayImplementations that do track wether or not the proxy is a reactive or readonly one.

Consequently, this doesn't result in tracking:

readonly([1, 2])[0]

but this does:

readonly([1, 2]).includes(1)

close: #2493

@LinusBorg LinusBorg changed the title fix(reactivity): ensure readonly on plain arrays doesn't track array methods. fix(reactivity): ensure readonly on plain arrays doesn't track array methods. (close: #2493) Oct 28, 2020
@github-actions
Copy link

Size report

Path Size
vue.global.prod.js 40.15 KB (-0.01% 🔽)
runtime-dom.global.prod.js 26.43 KB (-0.01% 🔽)
size-check.global.prod.js 15.95 KB (-0.01% 🔽)

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.

readonly(["a", "b", "c"]).includes() tracks dependencies even though array is nonreactive
2 participants