Skip to content

Commit f3623e4

Browse files
committed
fix(compiler-core): fix prod whitespace/comment removal
fix #1256
1 parent b942a31 commit f3623e4

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

packages/compiler-core/src/parse.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,17 @@ function parseChildren(
216216
removedWhitespace = true
217217
nodes[i] = null as any
218218
} else {
219-
// Otherwise, condensed consecutive whitespace inside the text down to
220-
// a single space
219+
// Otherwise, condensed consecutive whitespace inside the text
220+
// down to a single space
221221
node.content = ' '
222222
}
223223
} else {
224224
node.content = node.content.replace(/[\t\r\n\f ]+/g, ' ')
225225
}
226+
} else if (!__DEV__ && node.type === NodeTypes.COMMENT) {
227+
// remove comment nodes in prod
228+
removedWhitespace = true
229+
nodes[i] = null as any
226230
}
227231
}
228232
} else if (parent && context.options.isPreTag(parent.tag)) {
@@ -239,12 +243,6 @@ function parseChildren(
239243
}
240244

241245
function pushNode(nodes: TemplateChildNode[], node: TemplateChildNode): void {
242-
// ignore comments in production
243-
/* istanbul ignore next */
244-
if (!__DEV__ && node.type === NodeTypes.COMMENT) {
245-
return
246-
}
247-
248246
if (node.type === NodeTypes.TEXT) {
249247
const prev = last(nodes)
250248
// Merge if both this and the previous node are text and those are

0 commit comments

Comments
 (0)