Skip to content

Array directly inside array does not get watched #3883

Closed
@amcsi

Description

@amcsi

Vue.js version

2.0.1

Reproduction Link

http://jsfiddle.net/amcsi/o9v0ayrw/7/

Steps to reproduce

  1. Press Create Text
  2. Press the + button

What is Expected?

The text should have appeared right when pressing Create Text; instead you had to press +

What is actually happening?

On first instantiation of the VueJS app, if you observer the initial data, you'll see that the inner array doesn't have any watchers assigned to it; there is the inner loop in the template that iterates that array, so I'd expect a watcher be created for that.

Interestingly if any other vue method is triggered that is being watched by vue, the view appears to refresh and the texts that have been added to the inner array now appear apparently.

Here is a longer example of a commit where I fixed the issue in my real world case:
amcsi/skill-builder@9fd3e7e

I was using an empty array directly within an array, and that empty array didn't have any watchers automatically set even though I was iterating it in the template. By changing the inner array to instead be an object with a property with that empty array, I was able to get watchers to watch the empty array.

I think this is bug; you shouldn't have to wrap your arrays in objects if you don't want to I think.

EDIT: updated description according to JSFiddle reproduction

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