File tree 3 files changed +16
-4
lines changed
3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -194,7 +194,7 @@ function parseChildren(
194
194
for ( let i = 0 ; i < nodes . length ; i ++ ) {
195
195
const node = nodes [ i ]
196
196
if ( node . type === NodeTypes . TEXT ) {
197
- if ( ! node . content . trim ( ) ) {
197
+ if ( ! / [ ^ \t \r \n \f ] / . test ( node . content ) ) {
198
198
const prev = nodes [ i - 1 ]
199
199
const next = nodes [ i + 1 ]
200
200
// If:
@@ -219,7 +219,7 @@ function parseChildren(
219
219
node . content = ' '
220
220
}
221
221
} else {
222
- node . content = node . content . replace ( / \s + / g, ' ' )
222
+ node . content = node . content . replace ( / [ \t \r \n \f ] + / g, ' ' )
223
223
}
224
224
}
225
225
}
Original file line number Diff line number Diff line change 8
8
InterpolationNode
9
9
} from '@vue/compiler-core'
10
10
import {
11
- parserOptionsMinimal as parserOptions ,
11
+ parserOptionsStandard as parserOptions ,
12
12
DOMNamespaces
13
- } from '../src/parserOptionsMinimal '
13
+ } from '../src/parserOptionsStandard '
14
14
15
15
describe ( 'DOM parser' , ( ) => {
16
16
describe ( 'Text' , ( ) => {
@@ -160,6 +160,16 @@ describe('DOM parser', () => {
160
160
}
161
161
] )
162
162
} )
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
+ } )
163
173
} )
164
174
165
175
describe ( 'Interpolation' , ( ) => {
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ import { ParserOptions } from '@vue/compiler-core'
2
2
import { parserOptionsMinimal } from './parserOptionsMinimal'
3
3
import namedCharacterReferences from './namedChars.json'
4
4
5
+ export { DOMNamespaces } from './parserOptionsMinimal'
6
+
5
7
export const parserOptionsStandard : ParserOptions = {
6
8
// extends the minimal options with more spec-compliant overrides
7
9
...parserOptionsMinimal ,
You can’t perform that action at this time.
0 commit comments