fix(runtime-core): attrs should be readonly in functional components (#10767)
This commit is contained in:
parent
2d56816aa8
commit
e8fd6446d1
|
@ -17,7 +17,6 @@ import {
|
||||||
ref,
|
ref,
|
||||||
render,
|
render,
|
||||||
serializeInner,
|
serializeInner,
|
||||||
toRaw,
|
|
||||||
toRefs,
|
toRefs,
|
||||||
watch,
|
watch,
|
||||||
} from '@vue/runtime-test'
|
} from '@vue/runtime-test'
|
||||||
|
@ -129,12 +128,12 @@ describe('component props', () => {
|
||||||
render(h(Comp, { foo: 1 }), root)
|
render(h(Comp, { foo: 1 }), root)
|
||||||
expect(props).toEqual({ foo: 1 })
|
expect(props).toEqual({ foo: 1 })
|
||||||
expect(attrs).toEqual({ foo: 1 })
|
expect(attrs).toEqual({ foo: 1 })
|
||||||
expect(toRaw(props)).toBe(attrs)
|
expect(props).toBe(attrs)
|
||||||
|
|
||||||
render(h(Comp, { bar: 2 }), root)
|
render(h(Comp, { bar: 2 }), root)
|
||||||
expect(props).toEqual({ bar: 2 })
|
expect(props).toEqual({ bar: 2 })
|
||||||
expect(attrs).toEqual({ bar: 2 })
|
expect(attrs).toEqual({ bar: 2 })
|
||||||
expect(toRaw(props)).toBe(attrs)
|
expect(props).toBe(attrs)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('boolean casting', () => {
|
test('boolean casting', () => {
|
||||||
|
|
|
@ -116,7 +116,7 @@ export function renderComponentRoot(
|
||||||
? {
|
? {
|
||||||
get attrs() {
|
get attrs() {
|
||||||
markAttrsAccessed()
|
markAttrsAccessed()
|
||||||
return attrs
|
return shallowReadonly(attrs)
|
||||||
},
|
},
|
||||||
slots,
|
slots,
|
||||||
emit,
|
emit,
|
||||||
|
|
Loading…
Reference in New Issue