File tree Expand file tree Collapse file tree 3 files changed +16
-4
lines changed
Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -194,7 +194,7 @@ function parseChildren(
194194 for ( let i = 0 ; i < nodes . length ; i ++ ) {
195195 const node = nodes [ i ]
196196 if ( node . type === NodeTypes . TEXT ) {
197- if ( ! node . content . trim ( ) ) {
197+ if ( ! / [ ^ \t \r \n \f ] / . test ( node . content ) ) {
198198 const prev = nodes [ i - 1 ]
199199 const next = nodes [ i + 1 ]
200200 // If:
@@ -219,7 +219,7 @@ function parseChildren(
219219 node . content = ' '
220220 }
221221 } else {
222- node . content = node . content . replace ( / \s + / g, ' ' )
222+ node . content = node . content . replace ( / [ \t \r \n \f ] + / g, ' ' )
223223 }
224224 }
225225 }
Original file line number Diff line number Diff line change 88 InterpolationNode
99} from '@vue/compiler-core'
1010import {
11- parserOptionsMinimal as parserOptions ,
11+ parserOptionsStandard as parserOptions ,
1212 DOMNamespaces
13- } from '../src/parserOptionsMinimal '
13+ } from '../src/parserOptionsStandard '
1414
1515describe ( 'DOM parser' , ( ) => {
1616 describe ( 'Text' , ( ) => {
@@ -160,6 +160,16 @@ describe('DOM parser', () => {
160160 }
161161 ] )
162162 } )
163+
164+ // #945
165+ test ( ' should not be condensed' , ( ) => {
166+ const nbsp = String . fromCharCode ( 160 )
167+ const ast = parse ( `foo bar` , parserOptions )
168+ expect ( ast . children [ 0 ] ) . toMatchObject ( {
169+ type : NodeTypes . TEXT ,
170+ content : `foo${ nbsp } ${ nbsp } bar`
171+ } )
172+ } )
163173 } )
164174
165175 describe ( 'Interpolation' , ( ) => {
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ import { ParserOptions } from '@vue/compiler-core'
22import { parserOptionsMinimal } from './parserOptionsMinimal'
33import namedCharacterReferences from './namedChars.json'
44
5+ export { DOMNamespaces } from './parserOptionsMinimal'
6+
57export const parserOptionsStandard : ParserOptions = {
68 // extends the minimal options with more spec-compliant overrides
79 ...parserOptionsMinimal ,
You can’t perform that action at this time.
0 commit comments