Skip to content

The logic of Vue.set is unreasonable when handling array #8535

@FuuuOverclocking

Description

@FuuuOverclocking

Version

2.5.17-beta.0

Reproduction link

https://jsfiddle.net/L6pey1ts/22/

Steps to reproduce

Run JSFiddle snippet

What is expected?

I expect, that the program only outputs 2,3,5,7,11,13 (when executing arr.push(13)).

What is actually happening?

    (empty line)
2,3,5,7,11
arr.abc changed
arr.def
    (empty line)
2,3,5,7,11,13
    (empty line)
arr.def changed

abc is already existed on arr when app is initializing, and it is neglected for it was defined on an array.

def is set by Vue.set(), but it executes defineReactive(arr, 'def', 'arr.def') (src/core/observer/index.js line:225), and notifies the watchers.

Vue.set() should be consistent when dealing with them. In my mind, both of them should be neglected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions