Skip to content

Commit

Permalink
fix(compiler-core): fix prod whitespace/comment removal
Browse files Browse the repository at this point in the history
fix #1256
  • Loading branch information
yyx990803 committed Jun 11, 2020
1 parent b942a31 commit f3623e4
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions packages/compiler-core/src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,17 @@ function parseChildren(
removedWhitespace = true
nodes[i] = null as any
} else {
// Otherwise, condensed consecutive whitespace inside the text down to
// a single space
// Otherwise, condensed consecutive whitespace inside the text
// down to a single space
node.content = ' '
}
} else {
node.content = node.content.replace(/[\t\r\n\f ]+/g, ' ')
}
} else if (!__DEV__ && node.type === NodeTypes.COMMENT) {
// remove comment nodes in prod
removedWhitespace = true
nodes[i] = null as any
}
}
} else if (parent && context.options.isPreTag(parent.tag)) {
Expand All @@ -239,12 +243,6 @@ function parseChildren(
}

function pushNode(nodes: TemplateChildNode[], node: TemplateChildNode): void {
// ignore comments in production
/* istanbul ignore next */
if (!__DEV__ && node.type === NodeTypes.COMMENT) {
return
}

if (node.type === NodeTypes.TEXT) {
const prev = last(nodes)
// Merge if both this and the previous node are text and those are
Expand Down

0 comments on commit f3623e4

Please sign in to comment.