diff --git a/packages/runtime-core/__tests__/componentProps.spec.ts b/packages/runtime-core/__tests__/componentProps.spec.ts index 6fc5d4dd2d7..04fa4206396 100644 --- a/packages/runtime-core/__tests__/componentProps.spec.ts +++ b/packages/runtime-core/__tests__/componentProps.spec.ts @@ -11,15 +11,17 @@ import { getCurrentInstance, h, inject, + nextTick, nodeOps, provide, ref, render, serializeInner, + toRaw, toRefs, watch, } from '@vue/runtime-test' -import { render as domRender, nextTick } from 'vue' +import { render as domRender } from 'vue' describe('component props', () => { test('stateful', () => { @@ -127,12 +129,12 @@ describe('component props', () => { render(h(Comp, { foo: 1 }), root) expect(props).toEqual({ foo: 1 }) expect(attrs).toEqual({ foo: 1 }) - expect(props).toBe(attrs) + expect(toRaw(props)).toBe(attrs) render(h(Comp, { bar: 2 }), root) expect(props).toEqual({ bar: 2 }) expect(attrs).toEqual({ bar: 2 }) - expect(props).toBe(attrs) + expect(toRaw(props)).toBe(attrs) }) test('boolean casting', () => { diff --git a/packages/runtime-core/src/componentRenderUtils.ts b/packages/runtime-core/src/componentRenderUtils.ts index 6f4a1a2af76..31a1a5fa122 100644 --- a/packages/runtime-core/src/componentRenderUtils.ts +++ b/packages/runtime-core/src/componentRenderUtils.ts @@ -55,12 +55,12 @@ export function renderComponentRoot( emit, render, renderCache, + props, data, setupState, ctx, inheritAttrs, } = instance - const props = __DEV__ ? shallowReadonly(instance.props) : instance.props const prev = setCurrentRenderingInstance(instance) let result @@ -94,7 +94,7 @@ export function renderComponentRoot( thisProxy, proxyToUse!, renderCache, - props, + __DEV__ ? shallowReadonly(props) : props, setupState, data, ctx, @@ -111,7 +111,7 @@ export function renderComponentRoot( result = normalizeVNode( render.length > 1 ? render( - props, + __DEV__ ? shallowReadonly(props) : props, __DEV__ ? { get attrs() { @@ -123,7 +123,10 @@ export function renderComponentRoot( } : { attrs, slots, emit }, ) - : render(props, null as any /* we know it doesn't need it */), + : render( + __DEV__ ? shallowReadonly(props) : props, + null as any /* we know it doesn't need it */, + ), ) fallthroughAttrs = Component.props ? attrs