wip(ssr): revert reactivity ssr paths
The perf gains are not worth the correctness issues these paths may lead to
This commit is contained in:
parent
cc47ae0118
commit
763faac182
@ -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
|
// refs (in order to allow refs to be explicitly passed down), but should
|
||||||
// retain the reactivity of the normal readonly object.
|
// retain the reactivity of the normal readonly object.
|
||||||
export const shallowReadonlyHandlers: ProxyHandler<object> = {
|
export const shallowReadonlyHandlers: ProxyHandler<object> = {
|
||||||
|
@ -56,10 +56,6 @@ export function computed<T>(
|
|||||||
// expose effect so computed can be stopped
|
// expose effect so computed can be stopped
|
||||||
effect: runner,
|
effect: runner,
|
||||||
get value() {
|
get value() {
|
||||||
if (__SSR__) {
|
|
||||||
return getter()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dirty) {
|
if (dirty) {
|
||||||
value = runner()
|
value = runner()
|
||||||
dirty = false
|
dirty = false
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { isObject, toRawType, EMPTY_OBJ } from '@vue/shared'
|
import { isObject, toRawType } from '@vue/shared'
|
||||||
import {
|
import {
|
||||||
mutableHandlers,
|
mutableHandlers,
|
||||||
readonlyHandlers,
|
readonlyHandlers,
|
||||||
@ -77,7 +77,8 @@ export function readonly<T extends object>(
|
|||||||
|
|
||||||
// @internal
|
// @internal
|
||||||
// Return a reactive-copy of the original object, where only the root level
|
// 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.
|
// This is used for creating the props proxy object for stateful components.
|
||||||
export function shallowReadonly<T extends object>(
|
export function shallowReadonly<T extends object>(
|
||||||
target: T
|
target: T
|
||||||
@ -117,13 +118,7 @@ function createReactiveObject(
|
|||||||
if (!canObserve(target)) {
|
if (!canObserve(target)) {
|
||||||
return target
|
return target
|
||||||
}
|
}
|
||||||
const handlers = __SSR__
|
const handlers = collectionTypes.has(target.constructor)
|
||||||
? // 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
|
? collectionHandlers
|
||||||
: baseHandlers
|
: baseHandlers
|
||||||
observed = new Proxy(target, handlers)
|
observed = new Proxy(target, handlers)
|
||||||
|
@ -36,14 +36,6 @@ export function ref(value?: unknown) {
|
|||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
value = convert(value)
|
value = convert(value)
|
||||||
|
|
||||||
if (__SSR__) {
|
|
||||||
return {
|
|
||||||
_isRef: true,
|
|
||||||
value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const r = {
|
const r = {
|
||||||
_isRef: true,
|
_isRef: true,
|
||||||
get value() {
|
get value() {
|
||||||
@ -66,7 +58,7 @@ export function ref(value?: unknown) {
|
|||||||
export function toRefs<T extends object>(
|
export function toRefs<T extends object>(
|
||||||
object: T
|
object: T
|
||||||
): { [K in keyof T]: Ref<T[K]> } {
|
): { [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.`)
|
console.warn(`toRefs() expects a reactive object but received a plain one.`)
|
||||||
}
|
}
|
||||||
const ret: any = {}
|
const ret: any = {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user