Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compiler-core): generate the correct tree if comment is between if/else #1262

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions packages/compiler-core/src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,16 +239,15 @@ function parseChildren(
}
}

return removedWhitespace ? nodes.filter(Boolean) : nodes
const processedNodes = __DEV__
? nodes
: /// ignore comments in production check issue #1256
nodes.filter(x => !x || x.type !== NodeTypes.COMMENT)

return removedWhitespace ? processedNodes.filter(Boolean) : processedNodes
}

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