File tree 3 files changed +24
-4
lines changed
3 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -366,6 +366,7 @@ export interface GenericComponentInstance {
366
366
* @internal
367
367
*/
368
368
refs : Data
369
+ emit : EmitFn
369
370
/**
370
371
* used for keeping track of .once event handlers on components
371
372
* @internal
@@ -377,6 +378,10 @@ export interface GenericComponentInstance {
377
378
* @internal
378
379
*/
379
380
propsDefaults : Data | null
381
+ /**
382
+ * @internal
383
+ */
384
+ getRawProps : ( ) => Record < string , any > | null
380
385
381
386
// exposed properties via expose()
382
387
exposed : Record < string , any > | null
@@ -730,6 +735,7 @@ export function createComponentInstance(
730
735
731
736
// props default value
732
737
propsDefaults : null ,
738
+ getRawProps : null ! ,
733
739
734
740
// inheritAttrs
735
741
inheritAttrs : type . inheritAttrs ,
@@ -777,6 +783,7 @@ export function createComponentInstance(
777
783
}
778
784
instance . root = parent ? parent . root : instance
779
785
instance . emit = emit . bind ( null , instance )
786
+ instance . getRawProps = ( ) => instance . vnode . props
780
787
781
788
// apply custom element special handling
782
789
if ( vnode . ce ) {
Original file line number Diff line number Diff line change 1
1
import { type Ref , customRef , ref } from '@vue/reactivity'
2
2
import { EMPTY_OBJ , camelize , hasChanged , hyphenate } from '@vue/shared'
3
3
import type { DefineModelOptions , ModelRef } from '../apiSetupHelpers'
4
- import { getCurrentInstance } from '../component'
4
+ import { getCurrentGenericInstance } from '../component'
5
5
import { warn } from '../warning'
6
6
import type { NormalizedProps } from '../componentProps'
7
7
import { watchSyncEffect } from '../apiWatch'
@@ -23,14 +23,14 @@ export function useModel(
23
23
name : string ,
24
24
options : DefineModelOptions = EMPTY_OBJ ,
25
25
) : Ref {
26
- const i = getCurrentInstance ( ) !
26
+ const i = getCurrentGenericInstance ( ) !
27
27
if ( __DEV__ && ! i ) {
28
28
warn ( `useModel() called without active instance.` )
29
29
return ref ( ) as any
30
30
}
31
31
32
32
const camelizedName = camelize ( name )
33
- if ( __DEV__ && ! ( i . propsOptions [ 0 ] as NormalizedProps ) [ camelizedName ] ) {
33
+ if ( __DEV__ && ! ( i . propsOptions ! [ 0 ] as NormalizedProps ) [ camelizedName ] ) {
34
34
warn ( `useModel() called with prop "${ name } " which is not declared.` )
35
35
return ref ( ) as any
36
36
}
@@ -65,7 +65,7 @@ export function useModel(
65
65
) {
66
66
return
67
67
}
68
- const rawProps = i . vnode ! . props
68
+ const rawProps = i . getRawProps ( )
69
69
if (
70
70
! (
71
71
rawProps &&
Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ import {
50
50
import {
51
51
type DynamicPropsSource ,
52
52
type RawProps ,
53
+ getKeysFromRawProps ,
53
54
getPropsProxyHandlers ,
54
55
hasFallthroughAttrs ,
55
56
normalizePropsOptions ,
@@ -284,6 +285,7 @@ export class VaporComponentInstance implements GenericComponentInstance {
284
285
props : Record < string , any >
285
286
attrs : Record < string , any >
286
287
propsDefaults : Record < string , any > | null
288
+ getRawProps : ( ) => Record < string , any >
287
289
288
290
slots : StaticSlots
289
291
@@ -393,6 +395,17 @@ export class VaporComponentInstance implements GenericComponentInstance {
393
395
} else {
394
396
this . props = this . attrs = EMPTY_OBJ
395
397
}
398
+ this . getRawProps = ( ) => {
399
+ const keys = getKeysFromRawProps ( this . rawProps )
400
+ return keys . reduce (
401
+ ( props , key ) => {
402
+ // TODO
403
+ props [ key ] = null
404
+ return props
405
+ } ,
406
+ { } as Record < string , any > ,
407
+ )
408
+ }
396
409
397
410
// init slots
398
411
this . rawSlots = rawSlots || EMPTY_OBJ
You can’t perform that action at this time.
0 commit comments