]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test: fix test case broken by b93f264
authorEvan You <yyx990803@gmail.com>
Mon, 22 Apr 2024 13:05:00 +0000 (21:05 +0800)
committerEvan You <yyx990803@gmail.com>
Mon, 22 Apr 2024 13:05:00 +0000 (21:05 +0800)
packages/runtime-core/__tests__/componentProps.spec.ts
packages/runtime-core/src/componentRenderUtils.ts

index 6fc5d4dd2d72e7833c2eb2ef7ed08a9867efef5a..04fa4206396ad6b7252723db10f42ca6b55f41b6 100644 (file)
@@ -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', () => {
index 6f4a1a2af7614146462722b484989e0dd2ffdba4..31a1a5fa122f394f59268f4911eb87508b6e275f 100644 (file)
@@ -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