File tree 3 files changed +16
-23
lines changed
3 files changed +16
-23
lines changed Original file line number Diff line number Diff line change @@ -381,7 +381,7 @@ export interface GenericComponentInstance {
381
381
/**
382
382
* @internal
383
383
*/
384
- getRawProps : ( ) => Record < string , any > | null
384
+ getKeysFromRawProps : ( ) => string [ ] | undefined
385
385
386
386
// exposed properties via expose()
387
387
exposed : Record < string , any > | null
@@ -735,7 +735,7 @@ export function createComponentInstance(
735
735
736
736
// props default value
737
737
propsDefaults : null ,
738
- getRawProps : null ! ,
738
+ getKeysFromRawProps : null ! , // to be set immediately
739
739
740
740
// inheritAttrs
741
741
inheritAttrs : type . inheritAttrs ,
@@ -783,7 +783,10 @@ export function createComponentInstance(
783
783
}
784
784
instance . root = parent ? parent . root : instance
785
785
instance . emit = emit . bind ( null , instance )
786
- instance . getRawProps = ( ) => instance . vnode . props
786
+ instance . getKeysFromRawProps = ( ) => {
787
+ const { props } = instance . vnode
788
+ if ( props ) return Object . keys ( props )
789
+ }
787
790
788
791
// apply custom element special handling
789
792
if ( vnode . ce ) {
Original file line number Diff line number Diff line change @@ -65,17 +65,17 @@ export function useModel(
65
65
) {
66
66
return
67
67
}
68
- const rawProps = i . getRawProps ( )
68
+ const rawPropKeys = i . getKeysFromRawProps ( )
69
69
if (
70
70
! (
71
- rawProps &&
71
+ rawPropKeys &&
72
72
// check if parent has passed v-model
73
- ( name in rawProps ||
74
- camelizedName in rawProps ||
75
- hyphenatedName in rawProps ) &&
76
- ( `onUpdate:${ name } ` in rawProps ||
77
- `onUpdate:${ camelizedName } ` in rawProps ||
78
- `onUpdate:${ hyphenatedName } ` in rawProps )
73
+ ( rawPropKeys . includes ( name ) ||
74
+ rawPropKeys . includes ( camelizedName ) ||
75
+ rawPropKeys . includes ( hyphenatedName ) ) &&
76
+ ( rawPropKeys . includes ( `onUpdate:${ name } ` ) ||
77
+ rawPropKeys . includes ( `onUpdate:${ camelizedName } ` ) ||
78
+ rawPropKeys . includes ( `onUpdate:${ hyphenatedName } ` ) )
79
79
)
80
80
) {
81
81
// no v-model, local update
Original file line number Diff line number Diff line change @@ -285,7 +285,7 @@ export class VaporComponentInstance implements GenericComponentInstance {
285
285
props : Record < string , any >
286
286
attrs : Record < string , any >
287
287
propsDefaults : Record < string , any > | null
288
- getRawProps : ( ) => Record < string , any >
288
+ getKeysFromRawProps : ( ) => string [ ] | undefined
289
289
290
290
slots : StaticSlots
291
291
@@ -395,17 +395,7 @@ export class VaporComponentInstance implements GenericComponentInstance {
395
395
} else {
396
396
this . props = this . attrs = EMPTY_OBJ
397
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
- }
398
+ this . getKeysFromRawProps = ( ) => getKeysFromRawProps ( this . rawProps )
409
399
410
400
// init slots
411
401
this . rawSlots = rawSlots || EMPTY_OBJ
You can’t perform that action at this time.
0 commit comments