From 1a4bbed5025b9f1deb8294d568cf419d27b99a5e Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Sun, 10 May 2020 23:49:37 +0100 Subject: [PATCH] fix: revert data sanitisation --- src/ssr-ref.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ssr-ref.ts b/src/ssr-ref.ts index 0c4a88e6..dd91095f 100644 --- a/src/ssr-ref.ts +++ b/src/ssr-ref.ts @@ -15,6 +15,8 @@ export function setSSRContext(ssrContext: any) { const isProxyable = (val: unknown): val is object => val && typeof val === 'object' +const sanitise = (val: unknown) => val + /** * Creates a Ref that is in sync with the client. */ @@ -32,7 +34,7 @@ export const ssrRef = (value: T | (() => T), key?: string): Ref => { const val = getValue(value) const _ref = ref(val) - if (value instanceof Function) data[key] = val + if (value instanceof Function) data[key] = sanitise(val) const getProxy = >(observable: T): T => new Proxy(observable, { @@ -41,7 +43,7 @@ export const ssrRef = (value: T | (() => T), key?: string): Ref => { return Reflect.get(target, prop) }, set(obj, prop, val) { - data[key] = JSON.parse(JSON.stringify(_ref.value)) + data[key] = sanitise(_ref.value) return Reflect.set(obj, prop, val) }, }) @@ -49,7 +51,7 @@ export const ssrRef = (value: T | (() => T), key?: string): Ref => { const proxy = computed({ get: () => (isProxyable(_ref.value) ? getProxy(_ref.value) : _ref.value), set: v => { - data[key] = JSON.parse(JSON.stringify(v)) + data[key] = sanitise(v) _ref.value = v }, })