]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(runtime-core): attrs should be readonly in functional components (#10767)
authorskirtle <65301168+skirtles-code@users.noreply.github.com>
Mon, 29 Apr 2024 06:37:11 +0000 (07:37 +0100)
committerGitHub <noreply@github.com>
Mon, 29 Apr 2024 06:37:11 +0000 (14:37 +0800)
packages/runtime-core/__tests__/componentProps.spec.ts
packages/runtime-core/src/componentRenderUtils.ts

index 04fa4206396ad6b7252723db10f42ca6b55f41b6..1cc43c91bc2c182ad70ed6c5850247ebaf6fdbbb 100644 (file)
@@ -17,7 +17,6 @@ import {
   ref,
   render,
   serializeInner,
-  toRaw,
   toRefs,
   watch,
 } from '@vue/runtime-test'
@@ -129,12 +128,12 @@ describe('component props', () => {
     render(h(Comp, { foo: 1 }), root)
     expect(props).toEqual({ foo: 1 })
     expect(attrs).toEqual({ foo: 1 })
-    expect(toRaw(props)).toBe(attrs)
+    expect(props).toBe(attrs)
 
     render(h(Comp, { bar: 2 }), root)
     expect(props).toEqual({ bar: 2 })
     expect(attrs).toEqual({ bar: 2 })
-    expect(toRaw(props)).toBe(attrs)
+    expect(props).toBe(attrs)
   })
 
   test('boolean casting', () => {
index 31a1a5fa122f394f59268f4911eb87508b6e275f..3044884669a3a21fb91c2b08999918d682173d79 100644 (file)
@@ -116,7 +116,7 @@ export function renderComponentRoot(
                 ? {
                     get attrs() {
                       markAttrsAccessed()
-                      return attrs
+                      return shallowReadonly(attrs)
                     },
                     slots,
                     emit,