Skip to content

Commit

Permalink
fix(runtime-core): attrs should be readonly in functional components (v…
Browse files Browse the repository at this point in the history
  • Loading branch information
skirtles-code authored and lynxlangya committed May 30, 2024
1 parent af9425d commit 9ed7b81
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions packages/runtime-core/__tests__/componentProps.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
ref,
render,
serializeInner,
toRaw,
toRefs,
watch,
} from '@vue/runtime-test'
Expand Down Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-core/src/componentRenderUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export function renderComponentRoot(
? {
get attrs() {
markAttrsAccessed()
return attrs
return shallowReadonly(attrs)
},
slots,
emit,
Expand Down

0 comments on commit 9ed7b81

Please sign in to comment.