{
id: 'test'
},
- 'hello'
+ [h('span', 'foo'), 'hello']
)
}
}
const root = nodeOps.createElement('div')
render(h(App), root)
- expect(serialize(root)).toEqual(`<div><div id="test">hello</div></div>`)
+ expect(serialize(root)).toEqual(
+ `<div><div id="test"><span>foo</span>hello</div></div>`
+ )
expect(serialize(root, 2)).toEqual(
`<div>
<div id="test">
+ <span>
+ foo
+ </span>
hello
</div>
</div>`
return `${key}=${JSON.stringify(node.props[key])}`
})
.join(' ')
+ const newLine = indent ? `\n` : ``
const children = node.children.length
- ? (indent ? `\n` : ``) +
- node.children.map(c => serialize(c, indent, depth + 1)) +
- (indent ? `\n` : ``)
+ ? newLine +
+ node.children.map(c => serialize(c, indent, depth + 1)).join(newLine) +
+ newLine
: ``
const padding = indent ? ` `.repeat(indent).repeat(depth) : ``
return (