Skip to content

Commit

Permalink
test: fix test case broken by b93f264
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Apr 22, 2024
1 parent b93f264 commit a7cf742
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
8 changes: 5 additions & 3 deletions packages/runtime-core/__tests__/componentProps.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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', () => {
Expand Down
11 changes: 7 additions & 4 deletions packages/runtime-core/src/componentRenderUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -94,7 +94,7 @@ export function renderComponentRoot(
thisProxy,
proxyToUse!,
renderCache,
props,
__DEV__ ? shallowReadonly(props) : props,

This comment has been minimized.

Copy link
@edison1105

edison1105 Apr 22, 2024

Member

Actually https://github.com/vuejs/core/pull/8222/files to do the same thing. 😂

setupState,
data,
ctx,
Expand All @@ -111,7 +111,7 @@ export function renderComponentRoot(
result = normalizeVNode(
render.length > 1
? render(
props,
__DEV__ ? shallowReadonly(props) : props,
__DEV__
? {
get attrs() {
Expand All @@ -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
Expand Down

0 comments on commit a7cf742

Please sign in to comment.