Skip to content

Commit e8fd644

Browse files
fix(runtime-core): attrs should be readonly in functional components (#10767)
1 parent 2d56816 commit e8fd644

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

packages/runtime-core/__tests__/componentProps.spec.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
ref,
1818
render,
1919
serializeInner,
20-
toRaw,
2120
toRefs,
2221
watch,
2322
} from '@vue/runtime-test'
@@ -129,12 +128,12 @@ describe('component props', () => {
129128
render(h(Comp, { foo: 1 }), root)
130129
expect(props).toEqual({ foo: 1 })
131130
expect(attrs).toEqual({ foo: 1 })
132-
expect(toRaw(props)).toBe(attrs)
131+
expect(props).toBe(attrs)
133132

134133
render(h(Comp, { bar: 2 }), root)
135134
expect(props).toEqual({ bar: 2 })
136135
expect(attrs).toEqual({ bar: 2 })
137-
expect(toRaw(props)).toBe(attrs)
136+
expect(props).toBe(attrs)
138137
})
139138

140139
test('boolean casting', () => {

packages/runtime-core/src/componentRenderUtils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export function renderComponentRoot(
116116
? {
117117
get attrs() {
118118
markAttrsAccessed()
119-
return attrs
119+
return shallowReadonly(attrs)
120120
},
121121
slots,
122122
emit,

0 commit comments

Comments
 (0)