@@ -198,48 +198,48 @@ function parseChildren(
198
198
// (same as v2 whitespace: 'condense')
199
199
let removedWhitespace = false
200
200
if ( mode !== TextModes . RAWTEXT ) {
201
- if ( ! context . inPre ) {
202
- for ( let i = 0 ; i < nodes . length ; i ++ ) {
203
- const node = nodes [ i ]
204
- if ( node . type === NodeTypes . TEXT ) {
205
- if ( ! / [ ^ \t \r \n \f ] / . test ( node . content ) ) {
206
- const prev = nodes [ i - 1 ]
207
- const next = nodes [ i + 1 ]
208
- // If:
209
- // - the whitespace is the first or last node, or:
210
- // - the whitespace is adjacent to a comment, or:
211
- // - the whitespace is between two elements AND contains newline
212
- // Then the whitespace is ignored.
213
- if (
214
- ! prev ||
215
- ! next ||
216
- prev . type === NodeTypes . COMMENT ||
217
- next . type === NodeTypes . COMMENT ||
218
- ( prev . type === NodeTypes . ELEMENT &&
219
- next . type === NodeTypes . ELEMENT &&
220
- / [ \r \n ] / . test ( node . content ) )
221
- ) {
222
- removedWhitespace = true
223
- nodes [ i ] = null as any
224
- } else {
225
- // Otherwise, condensed consecutive whitespace inside the text
226
- // down to a single space
227
- node . content = ' '
228
- }
201
+ for ( let i = 0 ; i < nodes . length ; i ++ ) {
202
+ const node = nodes [ i ]
203
+ if ( ! context . inPre && node . type === NodeTypes . TEXT ) {
204
+ if ( ! / [ ^ \t \r \n \f ] / . test ( node . content ) ) {
205
+ const prev = nodes [ i - 1 ]
206
+ const next = nodes [ i + 1 ]
207
+ // If:
208
+ // - the whitespace is the first or last node, or:
209
+ // - the whitespace is adjacent to a comment, or:
210
+ // - the whitespace is between two elements AND contains newline
211
+ // Then the whitespace is ignored.
212
+ if (
213
+ ! prev ||
214
+ ! next ||
215
+ prev . type === NodeTypes . COMMENT ||
216
+ next . type === NodeTypes . COMMENT ||
217
+ ( prev . type === NodeTypes . ELEMENT &&
218
+ next . type === NodeTypes . ELEMENT &&
219
+ / [ \r \n ] / . test ( node . content ) )
220
+ ) {
221
+ removedWhitespace = true
222
+ nodes [ i ] = null as any
229
223
} else {
230
- node . content = node . content . replace ( / [ \t \r \n \f ] + / g, ' ' )
224
+ // Otherwise, condensed consecutive whitespace inside the text
225
+ // down to a single space
226
+ node . content = ' '
231
227
}
232
- } else if (
233
- ! __DEV__ &&
234
- node . type === NodeTypes . COMMENT &&
235
- ! context . options . comments
236
- ) {
237
- // remove comment nodes in prod by default
238
- removedWhitespace = true
239
- nodes [ i ] = null as any
228
+ } else {
229
+ node . content = node . content . replace ( / [ \t \r \n \f ] + / g, ' ' )
240
230
}
241
231
}
242
- } else if ( parent && context . options . isPreTag ( parent . tag ) ) {
232
+ // also remove comment nodes in prod by default
233
+ if (
234
+ ! __DEV__ &&
235
+ node . type === NodeTypes . COMMENT &&
236
+ ! context . options . comments
237
+ ) {
238
+ removedWhitespace = true
239
+ nodes [ i ] = null as any
240
+ }
241
+ }
242
+ if ( context . inPre && parent && context . options . isPreTag ( parent . tag ) ) {
243
243
// remove leading newline per html spec
244
244
// https://html.spec.whatwg.org/multipage/grouping-content.html#the-pre-element
245
245
const first = nodes [ 0 ]
0 commit comments