@@ -3,32 +3,33 @@ import { compatibleMemberDecorator, compatibleClassDecorator } from './deco3/uti
33import { type VueCons , Base } from './class' ;
44import { getSlot , type Slot , type SlotMapNames } from './slot'
55
6- export function makeObject ( names : string [ ] , obj : any ) {
7- return names . reduce < Record < string , any > > ( ( pv , cv ) => {
8- pv [ cv ] = obj [ cv ]
9- return pv
10- } , { } )
6+ export function getPrototypeOf ( proto : Identity ) : Identity | null {
7+ const p = Object . getPrototypeOf ( proto )
8+ if ( ! ( p instanceof Base ) ) {
9+ return null
10+ }
11+ return p
1112}
1213
13- export function toComponentReverse ( obj : any ) {
14- const arr : any [ ] = [ ]
15- let curr = obj
14+ export function toComponentReverse ( proto : Identity ) {
15+ const arr : Identity [ ] = [ ]
16+ let curr : Identity | null = proto
1617 do {
1718 arr . unshift ( curr )
18- curr = Object . getPrototypeOf ( curr )
19- } while ( curr . constructor !== Base && ! getSlot ( curr ) )
19+ curr = getPrototypeOf ( curr )
20+ } while ( curr !== null && ! getSlot ( curr ) )
2021 return arr
2122}
2223
23- export function getSuperSlot ( obj : any ) {
24- let curr = Object . getPrototypeOf ( obj )
24+ export function getSuperSlot ( proto : Identity ) {
25+ let curr = getPrototypeOf ( proto )
2526
26- while ( curr . constructor !== Base ) {
27+ while ( curr !== null ) {
2728 const slot = getSlot ( curr )
2829 if ( slot ) {
2930 return slot
3031 }
31- curr = Object . getPrototypeOf ( curr )
32+ curr = getPrototypeOf ( proto )
3233 }
3334 return null
3435}
0 commit comments