1
- import { defineComponent , ComponentCustomOptions } from 'vue' ;
1
+ import { defineComponent , ComponentCustomOptions } from 'vue' ;
2
2
import { obtainSlot , extendSlotPath } from './utils'
3
3
import { build as optionComputed } from './option/computed'
4
4
import { build as optionData } from './option/data'
@@ -57,7 +57,8 @@ type ComponentOption = {
57
57
expose ?: string [ ] ;
58
58
render ?: Function ;
59
59
modifier ?: ( raw : any ) => any
60
- options ?:ComponentCustomOptions & Record < string , any >
60
+ options ?: ComponentCustomOptions & Record < string , any >
61
+ template ?: string
61
62
}
62
63
type ComponentConsOption = Cons | ComponentOption
63
64
function ComponentStep ( cons : Cons , extend ?: any ) {
@@ -67,37 +68,23 @@ function ComponentStep(cons: Cons, extend?: any) {
67
68
function ComponentStepWithOption ( cons : Cons , arg : ComponentOption , extend ?: any ) : any {
68
69
let option = ComponentOption ( cons , extend )
69
70
const slot = obtainSlot ( cons . prototype )
70
- if ( typeof arg . name !== 'undefined' ) {
71
- option . name = arg . name
72
- }
71
+
72
+ Object . keys ( arg ) . reduce < Record < string , any > > ( ( option , name : string ) => {
73
+ if ( [ 'options' , 'modifier' , 'emits' ] . includes ( name ) ) {
74
+ return option
75
+ }
76
+ option [ name ] = arg [ name as keyof ComponentOption ]
77
+ return option
78
+ } , option )
73
79
74
80
let emits = Array . from ( slot . obtainMap ( 'emits' ) . keys ( ) )
75
81
if ( Array . isArray ( arg . emits ) ) {
76
82
emits = Array . from ( new Set ( [ ...emits , ...arg . emits ] ) )
77
83
}
78
84
option . emits = emits
79
85
80
-
81
- if ( arg . components ) {
82
- option . components = arg . components
83
- }
84
- if ( arg . provide ) {
85
- option . provide = arg . provide
86
- }
87
- if ( arg . directives ) {
88
- option . directives = arg . directives
89
- }
90
- if ( arg . inheritAttrs ) {
91
- option . inheritAttrs = arg . inheritAttrs
92
- }
93
- if ( arg . expose ) {
94
- option . expose = arg . expose
95
- }
96
- if ( arg . render ) {
97
- option . render = arg . render
98
- }
99
- if ( arg . options ) {
100
- Object . assign ( option , arg . options )
86
+ if ( arg . options ) {
87
+ Object . assign ( option , arg . options )
101
88
}
102
89
if ( arg . modifier ) {
103
90
option = arg . modifier ( option )
@@ -115,7 +102,6 @@ export function ComponentBase(cons: Cons) {
115
102
}
116
103
117
104
export function Component ( arg : ComponentConsOption ) {
118
-
119
105
function extend ( cons : Cons ) {
120
106
ComponentBase ( cons )
121
107
const slotPath = extendSlotPath ( cons . prototype )
0 commit comments