File tree Expand file tree Collapse file tree 2 files changed +10
-12
lines changed 
packages/svelte/src/compiler/phases/3-transform Expand file tree Collapse file tree 2 files changed +10
-12
lines changed Original file line number Diff line number Diff line change 1+ --- 
2+ ' svelte '  : patch 
3+ --- 
4+ 
5+ chore: simplify ` <pre> `  cleaning
Original file line number Diff line number Diff line change @@ -271,19 +271,12 @@ export function clean_nodes(
271271
272272	var  first  =  trimmed [ 0 ] ; 
273273
274- 	// initial newline inside a `<pre>` is disregarded, if not followed by another newline 
274+ 	// if first text node inside a <pre> is a single newline, discard it, because otherwise 
275+ 	// the browser will do it for us which could break hydration 
275276	if  ( parent . type  ===  'RegularElement'  &&  parent . name  ===  'pre'  &&  first ?. type  ===  'Text' )  { 
276- 		const  text  =  first . data . replace ( regex_starts_with_newline ,  '' ) ; 
277- 		if  ( text  !==  first . data )  { 
278- 			const  tmp  =  text . replace ( regex_starts_with_newline ,  '' ) ; 
279- 			if  ( text  ===  tmp )  { 
280- 				first . data  =  text ; 
281- 				first . raw  =  first . raw . replace ( regex_starts_with_newline ,  '' ) ; 
282- 				if  ( first . data  ===  '' )  { 
283- 					trimmed . shift ( ) ; 
284- 					first  =  trimmed [ 0 ] ; 
285- 				} 
286- 			} 
277+ 		if  ( first . data  ===  '\n'  ||  first . data  ===  '\r\n' )  { 
278+ 			trimmed . shift ( ) ; 
279+ 			first  =  trimmed [ 0 ] ; 
287280		} 
288281	} 
289282
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments