File tree Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,8 @@ interface MountingOptions<Props, Data = {}> {
47
47
? Partial < Data >
48
48
: never
49
49
props ?: Props
50
+ /** @deprecated */
51
+ propsData ?: Props
50
52
attrs ?: Record < string , unknown >
51
53
slots ?: SlotDictionary & {
52
54
default ?: Slot
@@ -258,6 +260,7 @@ export function mount(
258
260
// Vue's reactivity system will cause a rerender.
259
261
const props = reactive ( {
260
262
...options ?. attrs ,
263
+ ...options ?. propsData ,
261
264
...options ?. props ,
262
265
ref : MOUNT_COMPONENT_REF
263
266
} )
Original file line number Diff line number Diff line change @@ -20,6 +20,13 @@ expectType<string>(
20
20
} ) . vm . a
21
21
)
22
22
23
+ // accept propsData - vm is properly typed
24
+ expectType < string > (
25
+ mount ( AppWithDefine , {
26
+ propsData : { a : 'Hello' , b : 2 }
27
+ } ) . vm . a
28
+ )
29
+
23
30
// no data provided
24
31
expectError (
25
32
mount ( AppWithDefine , {
Original file line number Diff line number Diff line change @@ -26,6 +26,27 @@ describe('mountingOptions.props', () => {
26
26
expect ( wrapper . text ( ) ) . toBe ( 'Message is Hello' )
27
27
} )
28
28
29
+ test ( "passes props with 'propsData'" , ( ) => {
30
+ const wrapper = mount ( Component , {
31
+ propsData : {
32
+ message : 'Hello'
33
+ }
34
+ } )
35
+ expect ( wrapper . text ( ) ) . toBe ( 'Message is Hello' )
36
+ } )
37
+
38
+ test ( "uses props from 'props' attribute, when 'propsData' also contains same attribute keys" , ( ) => {
39
+ const wrapper = mount ( Component , {
40
+ propsData : {
41
+ message : 'Hello from propsData'
42
+ } ,
43
+ props : {
44
+ message : 'Hello from props'
45
+ }
46
+ } )
47
+ expect ( wrapper . text ( ) ) . toBe ( 'Message is Hello from props' )
48
+ } )
49
+
29
50
test ( 'assigns extra properties as attributes on components' , ( ) => {
30
51
const wrapper = mount ( Component , {
31
52
props : {
You can’t perform that action at this time.
0 commit comments