fix: should always generate slot for non-null children
This commit is contained in:
		
							parent
							
								
									a428218c64
								
							
						
					
					
						commit
						7c389606a4
					
				@ -109,6 +109,8 @@ export const h = ((tag: ElementType, data?: any, children?: any): VNode => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  // if value is observable, create a clone of original
 | 
					  // if value is observable, create a clone of original
 | 
				
			||||||
  // so that we can normalize its class/style
 | 
					  // so that we can normalize its class/style
 | 
				
			||||||
 | 
					  // since this guard is only placed here, this means any direct createXXXVnode
 | 
				
			||||||
 | 
					  // functions only accept fresh data objects.
 | 
				
			||||||
  if (isObservable(data)) {
 | 
					  if (isObservable(data)) {
 | 
				
			||||||
    data = Object.assign({}, data)
 | 
					    data = Object.assign({}, data)
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
				
			|||||||
@ -217,12 +217,11 @@ export function createComponentVNode(
 | 
				
			|||||||
      if (isFunction(children)) {
 | 
					      if (isFunction(children)) {
 | 
				
			||||||
        // function as children
 | 
					        // function as children
 | 
				
			||||||
        slots = { default: children }
 | 
					        slots = { default: children }
 | 
				
			||||||
      } else if (isArray(children) || (children as any)._isVNode) {
 | 
					      } else if (isObject(children) && !(children as any)._isVNode) {
 | 
				
			||||||
        // direct vnode children
 | 
					 | 
				
			||||||
        slots = { default: () => children }
 | 
					 | 
				
			||||||
      } else if (isObject(children)) {
 | 
					 | 
				
			||||||
        // slot object as children
 | 
					        // slot object as children
 | 
				
			||||||
        slots = children
 | 
					        slots = children
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        slots = { default: () => children }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      slots = normalizeSlots(slots)
 | 
					      slots = normalizeSlots(slots)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user