wip: update test runtime

This commit is contained in:
Evan You
2019-06-20 21:28:37 +08:00
parent 9c0f820a8e
commit 645c1eceea
7 changed files with 245 additions and 252 deletions

View File

@@ -1,4 +1,10 @@
import { TestElement, TestNode, NodeTypes, TestText } from './nodeOps'
import {
TestElement,
TestNode,
NodeTypes,
TestText,
TestComment
} from './nodeOps'
import { isOn } from '@vue/shared'
export function serialize(
@@ -37,7 +43,14 @@ function serializeElement(
)
}
function serializeText(node: TestText, indent: number, depth: number): string {
function serializeText(
node: TestText | TestComment,
indent: number,
depth: number
): string {
const padding = indent ? ` `.repeat(indent).repeat(depth) : ``
return padding + node.text
return (
padding +
(node.type === NodeTypes.COMMENT ? `<!--${node.text}-->` : node.text)
)
}