Commit Graph

13 Commits

Author SHA1 Message Date
XinPing Wang
8bab78b648 test: reactive proto 2020-05-03 15:36:19 -04:00
Evan You
09b4202a22 refactor(reactivity): adjust APIs
BREAKING CHANGE: Reactivity APIs adjustments:

- `readonly` is now non-tracking if called on plain objects.
  `lock` and `unlock` have been removed. A `readonly` proxy can no
  longer be directly mutated. However, it can still wrap an already
  reactive object and track changes to the source reactive object.

- `isReactive` now only returns true for proxies created by `reactive`,
   or a `readonly` proxy that wraps a `reactive` proxy.

- A new utility `isProxy` is introduced, which returns true for both
  reactive or readonly proxies.

- `markNonReactive` has been renamed to `markRaw`.
2020-04-15 16:45:20 -04:00
Evan You
1b2149dbb2 fix(reactivity): should not observe frozen objects
fix #867
2020-03-23 11:28:20 -04:00
Evan You
775a7c2b41 refactor: preserve refs in reactive arrays
BREAKING CHANGE: reactive arrays no longer unwraps contained refs

    When reactive arrays contain refs, especially a mix of refs and
    plain values, Array prototype methods will fail to function
    properly - e.g. sort() or reverse() will overwrite the ref's value
    instead of moving it (see #737).

    Ensuring correct behavior for all possible Array methods while
    retaining the ref unwrapping behavior is exceedinly complicated; In
    addition, even if Vue handles the built-in methods internally, it
    would still break when the user attempts to use a 3rd party utility
    functioon (e.g. lodash) on a reactive array containing refs.

    After this commit, similar to other collection types like Map and
    Set, Arrays will no longer automatically unwrap contained refs.

    The usage of mixed refs and plain values in Arrays should be rare in
    practice. In cases where this is necessary, the user can create a
    computed property that performs the unwrapping.
2020-02-21 17:48:39 +01:00
Dmitry Sharshakov
7f38c1e0ff
feat(reactivity): add shallowReactive function (#689) 2020-02-04 10:15:27 -05:00
Evan You
aefb7d282e fix(reactivity): Array methods relying on identity should work with raw values 2020-01-23 13:42:31 -05:00
Evan You
2569890e31 refactor: move mockWarn utility to @vue/shared
close #652
2020-01-22 09:29:45 -05:00
Evan You
1c56d1bf19 test: test unwrapping computed refs 2019-10-14 11:21:09 -04:00
相学长
cbb4b19cfb feat(reactivity): ref(Ref) should return Ref (#180) 2019-10-10 11:34:42 -04:00
Carlos Rodrigues
600ec5de42 chore: improve typings in reactivity tests (#96) 2019-10-05 10:39:40 -04:00
Evan You
3efe0ba3cd test: jest warning assert utils 2019-08-26 16:08:23 -04:00
Evan You
aacad85058 test: fix reactivity tests 2019-08-20 09:58:10 -04:00
Evan You
caba6d5c9e wip: state -> reactive, value -> ref 2019-08-16 09:42:46 -04:00