File tree Expand file tree Collapse file tree 2 files changed +3
-1
lines changed Expand file tree Collapse file tree 2 files changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ declare type CompilerOptions = {
1010 mustUseProp ?: ( attr : string ) => ?boolean , // check if an attribute should be bound as a property
1111 getTagNamespace ?: ( tag : string ) => ?string , // check the namespace for a tag
1212 transforms ?: Array < Function > , // a list of transforms on parsed AST before codegen
13+ preserveWhitespace ?: boolean ,
1314
1415 // runtime user-configurable
1516 delimiters ?: [ string , string ] // template delimiters
Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ export function parse (
5151 postTransforms = pluckModuleFunction ( options . modules , 'postTransformNode' )
5252 delimiters = options . delimiters
5353 const stack = [ ]
54+ const preserveWhitespace = options . preserveWhitespace !== false
5455 let root
5556 let currentParent
5657 let inPre = false
@@ -202,7 +203,7 @@ export function parse (
202203 text = currentParent . tag === 'pre' || text . trim ( )
203204 ? decodeHTMLCached ( text )
204205 // only preserve whitespace if its not right after a starting tag
205- : currentParent . children . length ? ' ' : ''
206+ : preserveWhitespace && currentParent . children . length ? ' ' : ''
206207 if ( text ) {
207208 let expression
208209 if ( ! inPre && text !== ' ' && ( expression = parseText ( text , delimiters ) ) ) {
You can’t perform that action at this time.
0 commit comments