fix #5592: comment vnode should not be merged into text vnode. (#5593)

* comment vnode should not be merged into text vnode.

* add isFalse helper

* delete trailing spaces
This commit is contained in:
maggiehe 2017-05-07 21:39:04 +08:00 committed by Evan You
parent b977c77d34
commit a8da4fb051
2 changed files with 5 additions and 2 deletions

View File

@ -1,7 +1,7 @@
/* @flow */
import VNode, { createTextVNode } from 'core/vdom/vnode'
import { isDef, isUndef, isPrimitive } from 'shared/util'
import { isFalse, isDef, isUndef, isPrimitive } from 'shared/util'
// The template compiler attempts to minimize the need for normalization by
// statically analyzing the template at compile time.
@ -54,7 +54,7 @@ function normalizeArrayChildren (children: any, nestedIndex?: string): Array<VNo
res.push(createTextVNode(c))
}
} else {
if (isDef(c.text) && isDef(last) && isDef(last.text)) {
if (isFalse(c.isComment) && isDef(c.text) && isDef(last) && isFalse(last.isComment) && isDef(last.text)) {
res[res.length - 1] = createTextVNode(last.text + c.text)
} else {
// default key for nested array children (likely generated by v-for)

View File

@ -14,6 +14,9 @@ export function isTrue (v: any): boolean %checks {
return v === true
}
export function isFalse (v: any): boolean %checks {
return v === false
}
/**
* Check if value is primitive
*/