preact-render-to-string
Advanced tools
Comparing version 3.6.0 to 3.6.1
@@ -69,3 +69,3 @@ (function (global, factory) { | ||
} | ||
return str; | ||
return str || undefined; | ||
} | ||
@@ -149,2 +149,4 @@ | ||
var c = new nodeName(props, context); | ||
c._disable = c.__x = true; | ||
c.props = props; | ||
@@ -151,0 +153,0 @@ c.context = context; |
@@ -81,3 +81,3 @@ (function (global, factory) { | ||
} | ||
return str; | ||
return str || undefined; | ||
} | ||
@@ -161,2 +161,4 @@ | ||
var c = new nodeName(props, context); | ||
c._disable = c.__x = true; | ||
c.props = props; | ||
@@ -163,0 +165,0 @@ c.context = context; |
{ | ||
"name": "preact-render-to-string", | ||
"amdName": "preactRenderToString", | ||
"version": "3.6.0", | ||
"version": "3.6.1", | ||
"description": "Render JSX to an HTML string, with support for Preact components.", | ||
@@ -6,0 +6,0 @@ "main": "dist/index.js", |
@@ -87,2 +87,4 @@ import { objectKeys, encodeEntities, falsey, memoize, indent, isLargeString, styleObjToCss, hashToClassName, assign, getNodeProps } from './util'; | ||
let c = new nodeName(props, context); | ||
// turn off stateful re-rendering: | ||
c._disable = c.__x = true; | ||
c.props = props; | ||
@@ -89,0 +91,0 @@ c.context = context; |
@@ -49,3 +49,3 @@ // DOM properties that should NOT have "px" added when numeric | ||
} | ||
return str; | ||
return str || undefined; | ||
} | ||
@@ -52,0 +52,0 @@ |
import { render, shallowRender } from '../src'; | ||
import { h, Component } from 'preact'; | ||
import chai, { expect } from 'chai'; | ||
import { spy, match } from 'sinon'; | ||
import { spy, stub, match } from 'sinon'; | ||
import sinonChai from 'sinon-chai'; | ||
@@ -75,2 +75,9 @@ chai.use(sinonChai); | ||
it('should ignore empty object styles', () => { | ||
let rendered = render(<div style={{}} />), | ||
expected = `<div></div>`; | ||
expect(rendered).to.equal(expected); | ||
}); | ||
it('should render SVG elements', () => { | ||
@@ -464,2 +471,41 @@ let rendered = render(( | ||
}); | ||
describe('state locking', () => { | ||
it('should set _disable and __x to true', () => { | ||
let inst; | ||
class Foo extends Component { | ||
constructor(props, context) { | ||
super(props, context); | ||
inst = this; | ||
} | ||
render() { | ||
return <div />; | ||
} | ||
} | ||
expect(render(<Foo />)).to.equal('<div></div>'); | ||
expect(inst).to.have.property('_disable', true); | ||
expect(inst).to.have.property('__x', true); | ||
}); | ||
it('should prevent re-rendering', () => { | ||
const Bar = stub().returns(<div />); | ||
let count = 0; | ||
class Foo extends Component { | ||
componentWillMount() { | ||
this.forceUpdate(); | ||
} | ||
render() { | ||
return <Bar count={++count} />; | ||
} | ||
} | ||
expect(render(<Foo />)).to.equal('<div></div>'); | ||
expect(Bar).to.have.been.calledOnce.and.calledWithMatch({ count: 1 }); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
130761
1830