diff --git a/packages/core/src/h.ts b/packages/core/src/h.ts index 993a418a..f423ddeb 100644 --- a/packages/core/src/h.ts +++ b/packages/core/src/h.ts @@ -9,7 +9,7 @@ import { createFragment, createPortal } from './vdom' -import { isObservable } from '@vue/observer' +import { isObservable, unwrap } from '@vue/observer' export const Fragment = Symbol() export const Portal = Symbol() @@ -43,11 +43,10 @@ export const h = ((tag: ElementType, data?: any, children?: any): VNode => { if (data === void 0) data = null if (children === void 0) children = null - if (__DEV__ && isObservable(data)) { - console.warn( - `Do not used observed state as VNode data - always create fresh objects.`, - data - ) + // if value is observable, create a clone of original + // so that we can mutate it later on. + if (isObservable(data)) { + data = Object.assign({}, unwrap(data)) } let key = null