Skip to content

Array mutation methods misbehave under certain circumstances #1683

@simplesmiler

Description

@simplesmiler

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions