Skip to content

Commit 12bde13

Browse files
committed
fix when array in content
1 parent afa7021 commit 12bde13

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

lib/posthtml-render.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ function postHTMLRender(tree, options) {
5252
typeof node.content !== 'object' && (buf += node.content);
5353
return node.content;
5454
}
55+
56+
// treat as new root tree if node is an array
57+
if (Array.isArray(node)) {
58+
buf += html(node);
59+
return;
60+
}
61+
5562
var tag = node.tag || 'div';
5663
if (singleTags[tag]) {
5764
buf += '<'+ tag + attrs(node.attrs);

posthtml-render.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ describe('PostHTML-Render test', function() {
3131
expect(render({ content: [555] })).to.eql('<div>555</div>');
3232
});
3333

34+
it('node array in content', function () {
35+
expect(render({content: [
36+
[
37+
555,
38+
{tag: 'div', content: 666},
39+
777
40+
]
41+
]})).to.eql('<div>555<div>666</div>777</div>')
42+
})
43+
3444
it('string node', function() {
3545
expect(render(['Hello world!'])).to.eql('Hello world!');
3646
});

0 commit comments

Comments
 (0)