]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip(ssr): revert reactivity ssr paths
authorEvan You <yyx990803@gmail.com>
Mon, 27 Jan 2020 20:15:13 +0000 (15:15 -0500)
committerEvan You <yyx990803@gmail.com>
Mon, 27 Jan 2020 21:00:18 +0000 (16:00 -0500)
The perf gains are not worth the correctness issues these paths may lead to

packages/reactivity/src/baseHandlers.ts
packages/reactivity/src/computed.ts
packages/reactivity/src/reactive.ts
packages/reactivity/src/ref.ts

index cee6588988a2cb76e41436f4fd3b9270ef321d08..1b8a61150f5dba261bb7c2e06051d18a32cd355e 100644 (file)
@@ -165,7 +165,7 @@ export const readonlyHandlers: ProxyHandler<object> = {
   }
 }
 
-// props handlers are special in the sense that it should not unwrap top-level
+// Props handlers are special in the sense that it should not unwrap top-level
 // refs (in order to allow refs to be explicitly passed down), but should
 // retain the reactivity of the normal readonly object.
 export const shallowReadonlyHandlers: ProxyHandler<object> = {
index 4e2df4f85c89a7bb605d5c1c3e3f5b1f1cd2f42a..1f1d8ea43d7f76649f7aa941cd7ce8be4deac24c 100644 (file)
@@ -56,10 +56,6 @@ export function computed<T>(
     // expose effect so computed can be stopped
     effect: runner,
     get value() {
-      if (__SSR__) {
-        return getter()
-      }
-
       if (dirty) {
         value = runner()
         dirty = false
index 256c91e6b491a259bd7e0624b3a5fd0cc7499e96..971ddb6743e9d3351d482bc07dfaede7216d65fb 100644 (file)
@@ -1,4 +1,4 @@
-import { isObject, toRawType, EMPTY_OBJ } from '@vue/shared'
+import { isObject, toRawType } from '@vue/shared'
 import {
   mutableHandlers,
   readonlyHandlers,
@@ -77,7 +77,8 @@ export function readonly<T extends object>(
 
 // @internal
 // Return a reactive-copy of the original object, where only the root level
-// properties are readonly, and does not recursively convert returned properties.
+// properties are readonly, and does NOT unwrap refs nor recursively convert
+// returned properties.
 // This is used for creating the props proxy object for stateful components.
 export function shallowReadonly<T extends object>(
   target: T
@@ -117,15 +118,9 @@ function createReactiveObject(
   if (!canObserve(target)) {
     return target
   }
-  const handlers = __SSR__
-    ? // disable reactivity in SSR.
-      // NOTE: a potential caveat here is isReactive check may return different
-      // values on nested values on client/server. This should be very rare but
-      // we should keep an eye on this.
-      EMPTY_OBJ
-    : collectionTypes.has(target.constructor)
-      ? collectionHandlers
-      : baseHandlers
+  const handlers = collectionTypes.has(target.constructor)
+    ? collectionHandlers
+    : baseHandlers
   observed = new Proxy(target, handlers)
   toProxy.set(target, observed)
   toRaw.set(observed, target)
index 6b316588bcb4ee05c8ba8bd2a475f0c39138af1e..65e1b8dd01655f8aa905627837a07ebc6b4dadda 100644 (file)
@@ -36,14 +36,6 @@ export function ref(value?: unknown) {
     return value
   }
   value = convert(value)
-
-  if (__SSR__) {
-    return {
-      _isRef: true,
-      value
-    }
-  }
-
   const r = {
     _isRef: true,
     get value() {
@@ -66,7 +58,7 @@ export function ref(value?: unknown) {
 export function toRefs<T extends object>(
   object: T
 ): { [K in keyof T]: Ref<T[K]> } {
-  if (__DEV__ && !__SSR__ && !isReactive(object)) {
+  if (__DEV__ && !isReactive(object)) {
     console.warn(`toRefs() expects a reactive object but received a plain one.`)
   }
   const ret: any = {}