Skip to content

Commit e7f8d33

Browse files
authored
Merge pull request #57 from posthtml/milestone-2.0.3
Milestone 2.0.3
2 parents 19ab379 + f5cd69d commit e7f8d33

File tree

5 files changed

+30
-3
lines changed

5 files changed

+30
-3
lines changed

changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1+
## <small>2.0.3 (2021-06-04)</small>
2+
3+
* test: if in content has empty array, issue #56 ([95bad06](https://github.com/posthtml/posthtml-render/commit/95bad06)), closes [#56](https://github.com/posthtml/posthtml-render/issues/56)
4+
* fix: if in content has empty array, close #56 ([892d602](https://github.com/posthtml/posthtml-render/commit/892d602)), closes [#56](https://github.com/posthtml/posthtml-render/issues/56)
5+
6+
7+
18
## <small>2.0.2 (2021-06-03)</small>
29

10+
* 2.0.2 ([bcbdc60](https://github.com/posthtml/posthtml-render/commit/bcbdc60))
311
* fix: concate single tag ([a6764cf](https://github.com/posthtml/posthtml-render/commit/a6764cf))
412
* test: fix only one test ([60f598d](https://github.com/posthtml/posthtml-render/commit/60f598d))
513

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "posthtml-render",
3-
"version": "2.0.2",
3+
"version": "2.0.3",
44
"description": "Renders PostHTML Tree to HTML/XML",
55
"license": "MIT",
66
"repository": "posthtml/posthtml-render",

src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,17 @@ function render(tree?: Node | Node[], options: Options = {}): string {
7878
node === undefined ||
7979
node === null ||
8080
(typeof node === 'string' && node.length === 0) ||
81-
Number.isNaN(node)) {
81+
Number.isNaN(node)
82+
) {
8283
break;
8384
}
8485

8586
// Treat as new root tree if node is an array
8687
if (Array.isArray(node)) {
88+
if (node.length === 0) {
89+
continue;
90+
}
91+
8792
result += html(node);
8893

8994
break;

test/test-core.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,20 @@ test('{Content} {Array}', t => {
167167
t.is(render(fixture), expected);
168168
});
169169

170+
test('{Content} {Array<before empty array content>}', t => {
171+
const fixture = {
172+
content: [
173+
[],
174+
[
175+
{tag: 'style', content: 'body { color: red; }'}
176+
]
177+
]
178+
};
179+
const expected = '<div><style>body { color: red; }</style></div>';
180+
181+
t.is(render(fixture), expected);
182+
});
183+
170184
test('{Content} {Nested}', t => {
171185
const fixture = {
172186
content: [

0 commit comments

Comments
 (0)