Skip to content

[fixed] server side rendering for Modal component #719

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"build": "babel-node tools/build-cli.js",
"test-watch": "karma start",
"test": "npm run lint && npm run build && karma start --single-run",
"test": "npm run lint && npm run build && karma start --single-run && _mocha --compilers js:babel-core/register './test/server/*Spec.js'",
"lint": "eslint ./",
"docs-build": "babel-node tools/build-cli.js --docs-only",
"docs": "docs/dev-run",
Expand Down
7 changes: 3 additions & 4 deletions src/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const Modal = React.createClass({
let classes = {
modal: true,
fade: this.props.animation,
'in': !this.props.animation || !document.querySelectorAll
'in': !this.props.animation
};

let modal = (
Expand Down Expand Up @@ -72,11 +72,10 @@ const Modal = React.createClass({
renderBackdrop(modal) {
let classes = {
'modal-backdrop': true,
'fade': this.props.animation
fade: this.props.animation,
'in': !this.props.animation
};

classes.in = !this.props.animation || !document.querySelectorAll;

let onClick = this.props.backdrop === true ?
this.handleBackdropClick : null;

Expand Down
17 changes: 17 additions & 0 deletions test/server/ModalSpec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import {assert} from 'chai';
import Modal from '../../src/Modal.js';

describe('Modal', () => {
it('Should be rendered on the server side', function () {
let noOp = () => {};

assert.doesNotThrow(function renderOnServerSide() {
return React.renderToString(
<Modal onRequestHide={noOp}>
<strong>Message</strong>
</Modal>
);
});
});
});