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

Array mutation methods misbehave under certain circumstances #1683

Closed
simplesmiler opened this issue Nov 3, 2015 · 0 comments
Closed

Array mutation methods misbehave under certain circumstances #1683

simplesmiler opened this issue Nov 3, 2015 · 0 comments
Labels

Comments

@simplesmiler
Copy link
Member

Demo: http://jsfiddle.net/simplesmiler/nmsc5cry/4/
Explanation: Inside a component with a two-way synced array prop items, if items is assigned after items.push or any other method, then the assignment gets ignored.

Foreseeing the question "why mutate before assign", there are use cases. For example:

this.items = this.items.splice(start, length); // keep only elements from `start` to `start+length`

EDIT: Actually use case above can be solved without mutation, using slice instead of splice.


Credits to @Kerruba for raising the issue in chat.

@yyx990803 yyx990803 added the bug label Nov 3, 2015
yyx990803 added a commit that referenced this issue Nov 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants