File tree Expand file tree Collapse file tree 3 files changed +27
-10
lines changed Expand file tree Collapse file tree 3 files changed +27
-10
lines changed Original file line number Diff line number Diff line change @@ -191,14 +191,19 @@ const ComponentPublicInstanceHandlers = {
191191} ;
192192
193193function initSlots ( instance , instanceChildren ) {
194+ instance . slots = normalizeObjectSlots ( instanceChildren ) ;
195+ }
196+ function normalizeObjectSlots ( instanceChildren ) {
194197 let slots = { } ;
195198 if ( isStructObject ( instanceChildren ) ) {
196199 for ( const key in instanceChildren ) {
197- const slot = instanceChildren [ key ] ;
198- slots [ key ] = isArray ( slot ) ? slot : [ slot ] ;
200+ slots [ key ] = normalizeSlot ( instanceChildren [ key ] ) ;
199201 }
200202 }
201- instance . slots = slots ;
203+ return slots ;
204+ }
205+ function normalizeSlot ( value ) {
206+ return isArray ( value ) ? value : [ value ] ;
202207}
203208
204209function promiseEmit ( ) { }
Original file line number Diff line number Diff line change @@ -187,14 +187,19 @@ const ComponentPublicInstanceHandlers = {
187187} ;
188188
189189function initSlots ( instance , instanceChildren ) {
190+ instance . slots = normalizeObjectSlots ( instanceChildren ) ;
191+ }
192+ function normalizeObjectSlots ( instanceChildren ) {
190193 let slots = { } ;
191194 if ( isStructObject ( instanceChildren ) ) {
192195 for ( const key in instanceChildren ) {
193- const slot = instanceChildren [ key ] ;
194- slots [ key ] = isArray ( slot ) ? slot : [ slot ] ;
196+ slots [ key ] = normalizeSlot ( instanceChildren [ key ] ) ;
195197 }
196198 }
197- instance . slots = slots ;
199+ return slots ;
200+ }
201+ function normalizeSlot ( value ) {
202+ return isArray ( value ) ? value : [ value ] ;
198203}
199204
200205function promiseEmit ( ) { }
Original file line number Diff line number Diff line change 11import { isArray , isStructObject } from "../shared/type" ;
22
33export function initSlots ( instance , instanceChildren ) {
4+ instance . slots = normalizeObjectSlots ( instanceChildren ) ;
5+ } ;
6+
7+ export function normalizeObjectSlots ( instanceChildren ) {
48 let slots = { } ;
59 if ( isStructObject ( instanceChildren ) ) {
610 for ( const key in instanceChildren ) {
7- const slot = instanceChildren [ key ] ;
8- slots [ key ] = isArray ( slot ) ? slot : [ slot ] ;
11+ slots [ key ] = normalizeSlot ( instanceChildren [ key ] ) ;
912 }
1013 } ;
11- instance . slots = slots ;
12- } ;
14+ return slots ;
15+ }
16+
17+ export function normalizeSlot ( value ) {
18+ return isArray ( value ) ? value : [ value ] ;
19+ }
You can’t perform that action at this time.
0 commit comments