Skip to content

Commit

Permalink
Set display empty string as default
Browse files Browse the repository at this point in the history
  • Loading branch information
1000ch committed Dec 11, 2017
1 parent a9a23be commit 04a4588
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/index.js
Expand Up @@ -31,7 +31,7 @@ export default class ViewportObserver extends React.Component {

static defaultProps = {
tagName : 'div',
display : 'block',
display : '',
onChange : () => {},
onEnter : () => {},
onLeave : () => {},
Expand Down Expand Up @@ -105,9 +105,11 @@ export default class ViewportObserver extends React.Component {
props[key] = this.props[key];
});

props.style = {
display : this.props.display
};
if (this.props.display !== '') {
props.style = {
display : this.props.display
};
}

return React.createElement(this.props.tagName, {
...props,
Expand Down
5 changes: 4 additions & 1 deletion test/index.js
Expand Up @@ -19,11 +19,14 @@ describe('ViewportObserver', () => {
document.body.removeChild(div);
});

it('should be rendered as div default', () => {
it('should be rendered with default values', () => {
const component = TestUtils.renderIntoDocument(<ViewportObserver />);
const node = TestUtils.findRenderedDOMComponentWithTag(component, 'div');

assert.notEqual(node, null);

assert.equal(node.className, '');
assert.equal(node.style.display, '');
});

it('should be rendered as specified `tagName`', () => {
Expand Down

0 comments on commit 04a4588

Please sign in to comment.