feat: clone observable data instead of warning
This commit is contained in:
parent
03390f80a7
commit
3c49b30e17
@ -9,7 +9,7 @@ import {
|
|||||||
createFragment,
|
createFragment,
|
||||||
createPortal
|
createPortal
|
||||||
} from './vdom'
|
} from './vdom'
|
||||||
import { isObservable } from '@vue/observer'
|
import { isObservable, unwrap } from '@vue/observer'
|
||||||
|
|
||||||
export const Fragment = Symbol()
|
export const Fragment = Symbol()
|
||||||
export const Portal = 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 (data === void 0) data = null
|
||||||
if (children === void 0) children = null
|
if (children === void 0) children = null
|
||||||
|
|
||||||
if (__DEV__ && isObservable(data)) {
|
// if value is observable, create a clone of original
|
||||||
console.warn(
|
// so that we can mutate it later on.
|
||||||
`Do not used observed state as VNode data - always create fresh objects.`,
|
if (isObservable(data)) {
|
||||||
data
|
data = Object.assign({}, unwrap(data))
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let key = null
|
let key = null
|
||||||
|
Loading…
Reference in New Issue
Block a user