Skip to content

Commit 41a00ca

Browse files
committed
Update to preact 8, add test & fix for null child issue
1 parent 237eee4 commit 41a00ca

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"chai": "^3.5.0",
4747
"eslint": "^3.2.2",
4848
"mocha": "^3.0.0",
49-
"preact": "^7.1.0",
49+
"preact": "^8.1.0",
5050
"rollup": "^0.34.3",
5151
"rollup-plugin-babel": "^2.6.1",
5252
"rollup-plugin-commonjs": "^3.3.1",

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export default function renderToString(vnode, context, opts, inner, isSvgMode) {
181181
let childSvgMode = nodeName==='svg' ? true : nodeName==='foreignObject' ? false : isSvgMode,
182182
ret = renderToString(child, context, opts, true, childSvgMode);
183183
if (!hasLarge && pretty && isLargeString(ret)) hasLarge = true;
184-
pieces.push(ret);
184+
if (ret) pieces.push(ret);
185185
}
186186
}
187187
if (hasLarge) {

test/jsx.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ describe('jsx', () => {
9696
<a b={undefined}>bar</a>
9797
)).to.equal(`<a>bar</a>`);
9898
});
99-
99+
100100
it('should render attributes containing VNodes', () => {
101101
expect(renderJsx(
102102
<a b={<c />}>bar</a>
@@ -145,6 +145,19 @@ describe('jsx', () => {
145145
`);
146146
});
147147

148+
it('should skip null siblings', () => {
149+
expect(renderJsx(
150+
<jsx>
151+
<span/>
152+
{null}
153+
</jsx>
154+
)).to.deep.equal(dedent`
155+
<jsx>
156+
<span></span>
157+
</jsx>
158+
`);
159+
});
160+
148161
it('should skip functions if functions=false', () => {
149162
expect(renderJsx(
150163
<div onClick={() => {}} />,

0 commit comments

Comments
 (0)