@@ -160,12 +160,10 @@ function emit(instance, eventProperty, ...args) {
160160}
161161// TODO: 运行时扩展实例
162162function extendRuntimeInstance ( instance , extendApis = { } ) {
163- console . log ( "extendApis" , extendApis ) ;
164163 // XXX: 临时解决方案
165164 // TODO: 待完善扩展实例
166165 Object . keys ( extendApis ) . forEach ( key => {
167166 instance [ key ] = extendApis [ key ] ;
168- console . log ( key , extendApis [ key ] ) ;
169167 } ) ;
170168}
171169
@@ -174,7 +172,8 @@ function initProps(instance, rawProps = {}) {
174172}
175173
176174const PublicPropertiesMaps = {
177- "$el" : ( instance ) => instance . vnode . el ,
175+ $el : ( instance ) => instance . vnode . el ,
176+ $slots : ( instance ) => instance . slots ,
178177} ;
179178const ComponentPublicInstanceHandlers = {
180179 get ( { _instance } , key ) {
@@ -191,6 +190,10 @@ const ComponentPublicInstanceHandlers = {
191190 }
192191} ;
193192
193+ function initSlots ( instance , instanceChildren ) {
194+ instance . slots = instanceChildren || [ ] ;
195+ }
196+
194197function promiseEmit ( ) { }
195198
196199var instanceRuntimeExtendApis = /*#__PURE__*/ Object . freeze ( {
@@ -205,6 +208,7 @@ function createComponentInstance(vnode) {
205208 type : vnode . type ,
206209 setupState : { } ,
207210 props : { } ,
211+ slots : { } ,
208212 emit : ( instance , event ) => { } ,
209213 } ;
210214 // 官方Emit
@@ -216,7 +220,7 @@ function createComponentInstance(vnode) {
216220}
217221function setupComponent ( instance ) {
218222 initProps ( instance , instance . vnode . props ) ;
219- // initSlots();
223+ initSlots ( instance , instance . vnode . children ) ;
220224 setupStatefulComponent ( instance ) ;
221225}
222226function setupStatefulComponent ( instance ) {
@@ -306,7 +310,7 @@ function addAttrs(vnode, container) {
306310 }
307311}
308312function setupRenderEffect ( instance , container , initialVNode ) {
309- const subTree = instance . render . call ( instance . proxy ) ;
313+ const subTree = instance === null || instance === void 0 ? void 0 : instance . render . call ( instance . proxy ) ;
310314 patch ( subTree , container ) ;
311315 initialVNode . el = subTree . el ;
312316}
0 commit comments