File tree Expand file tree Collapse file tree 2 files changed +40
-2
lines changed Expand file tree Collapse file tree 2 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -69,8 +69,11 @@ export function diff(
6969	// If the previous diff bailed out, resume creating/hydrating. 
7070	if  ( oldVNode . _flags  &  MODE_SUSPENDED )  { 
7171		isHydrating  =  ! ! ( oldVNode . _flags  &  MODE_HYDRATE ) ; 
72- 		excessDomChildren  =  oldVNode . _component . _excess ; 
73- 		oldDom  =  newVNode . _dom  =  oldVNode . _dom  =  excessDomChildren [ 0 ] ; 
72+ 		if  ( oldVNode . _component . _excess )  { 
73+ 			excessDomChildren  =  oldVNode . _component . _excess ; 
74+ 			oldDom  =  newVNode . _dom  =  oldVNode . _dom  =  excessDomChildren [ 0 ] ; 
75+ 			oldVNode . _component . _excess  =  null ; 
76+ 		} 
7477	} 
7578
7679	if  ( ( tmp  =  options . _diff ) )  tmp ( newVNode ) ; 
Original file line number Diff line number Diff line change @@ -128,6 +128,41 @@ describe('createContext', () => {
128128		expect ( renders ) . to . equal ( 1 ) ; 
129129	} ) ; 
130130
131+ 	it ( 'skips referentially equal children to Provider w/ dom-node in between' ,  ( )  =>  { 
132+ 		const  {  Provider,  Consumer }  =  createContext ( null ) ; 
133+ 		let  set , 
134+ 			renders  =  0 ; 
135+ 		const  Layout  =  ( {  children } )  =>  { 
136+ 			renders ++ ; 
137+ 			return  children ; 
138+ 		} ; 
139+ 		class  State  extends  Component  { 
140+ 			constructor ( props )  { 
141+ 				super ( props ) ; 
142+ 				this . state  =  {  i : 0  } ; 
143+ 				set  =  this . setState . bind ( this ) ; 
144+ 			} 
145+ 			render ( )  { 
146+ 				const  {  children }  =  this . props ; 
147+ 				return  < Provider  value = { this . state } > { children } </ Provider > ; 
148+ 			} 
149+ 		} 
150+ 		const  App  =  ( )  =>  ( 
151+ 			< State > 
152+ 				< div > 
153+ 					< Layout > 
154+ 						< Consumer > { ( {  i } )  =>  < p > { i } </ p > } </ Consumer > 
155+ 					</ Layout > 
156+ 				</ div > 
157+ 			</ State > 
158+ 		) ; 
159+ 		render ( < App  /> ,  scratch ) ; 
160+ 		expect ( renders ) . to . equal ( 1 ) ; 
161+ 		set ( {  i : 2  } ) ; 
162+ 		rerender ( ) ; 
163+ 		expect ( renders ) . to . equal ( 1 ) ; 
164+ 	} ) ; 
165+ 
131166	it ( 'should preserve provider context through nesting providers' ,  done  =>  { 
132167		const  {  Provider,  Consumer }  =  createContext ( null ) ; 
133168		const  CONTEXT  =  {  a : 'a'  } ; 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments