1- import { defineComponent , ComponentCustomOptions } from 'vue' ;
1+ import { defineComponent , ComponentCustomOptions } from 'vue' ;
22import { obtainSlot , extendSlotPath } from './utils'
33import { build as optionComputed } from './option/computed'
44import { build as optionData } from './option/data'
@@ -57,7 +57,8 @@ type ComponentOption = {
5757 expose ?: string [ ] ;
5858 render ?: Function ;
5959 modifier ?: ( raw : any ) => any
60- options ?:ComponentCustomOptions & Record < string , any >
60+ options ?: ComponentCustomOptions & Record < string , any >
61+ template ?: string
6162}
6263type ComponentConsOption = Cons | ComponentOption
6364function ComponentStep ( cons : Cons , extend ?: any ) {
@@ -67,37 +68,23 @@ function ComponentStep(cons: Cons, extend?: any) {
6768function ComponentStepWithOption ( cons : Cons , arg : ComponentOption , extend ?: any ) : any {
6869 let option = ComponentOption ( cons , extend )
6970 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 )
7379
7480 let emits = Array . from ( slot . obtainMap ( 'emits' ) . keys ( ) )
7581 if ( Array . isArray ( arg . emits ) ) {
7682 emits = Array . from ( new Set ( [ ...emits , ...arg . emits ] ) )
7783 }
7884 option . emits = emits
7985
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 )
10188 }
10289 if ( arg . modifier ) {
10390 option = arg . modifier ( option )
@@ -115,7 +102,6 @@ export function ComponentBase(cons: Cons) {
115102}
116103
117104export function Component ( arg : ComponentConsOption ) {
118-
119105 function extend ( cons : Cons ) {
120106 ComponentBase ( cons )
121107 const slotPath = extendSlotPath ( cons . prototype )
0 commit comments