Skip to content

Commit

Permalink
Revert "[fixed] Make the modal portal render into body again (reactjs…
Browse files Browse the repository at this point in the history
…#176)"

This reverts commit 9089a2d.
  • Loading branch information
rogeriopvl committed Sep 7, 2016
1 parent e5b0181 commit a607308
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/components/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var Modal = React.createClass({
componentDidMount: function() {
this.node = document.createElement('div');
this.node.className = this.props.portalClassName;
document.body.appendChild(this.node);
AppElement.appendChild(this.node);
this.renderPortal(this.props);
},

Expand All @@ -62,7 +62,7 @@ var Modal = React.createClass({

componentWillUnmount: function() {
ReactDOM.unmountComponentAtNode(this.node);
document.body.removeChild(this.node);
AppElement.removeChild(this.node);
elementClass(document.body).remove('ReactModal__Body--open');
},

Expand Down
17 changes: 15 additions & 2 deletions specs/Modal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ describe('Modal', function () {
unmountModal();
});

it('uses the global appElement', function() {
var app = document.createElement('div');
var node = document.createElement('div');
Modal.setAppElement(app);
ReactDOM.render(React.createElement(Modal, {isOpen: true}), node);
var modalParent = app.querySelector('.ReactModalPortal').parentNode;
assert.notEqual(modalParent, document.body);
assert.equal(modalParent, app);
equal(app.getAttribute('aria-hidden'), 'true');
ariaAppHider.resetForTesting();
ReactDOM.unmountComponentAtNode(node);
});

it('accepts appElement as a prop', function() {
var el = document.createElement('div');
var node = document.createElement('div');
Expand All @@ -41,10 +54,10 @@ describe('Modal', function () {
var node = document.createElement('div');
var App = React.createClass({
render: function() {
return React.DOM.div({}, React.createElement(Modal, {isOpen: true}, 'hello'));
return React.DOM.div({}, React.createElement(Modal, {isOpen: true, ariaHideApp: false}, 'hello'));
}
});
Modal.setAppElement(node);
Modal.setAppElement(document.body);
ReactDOM.render(React.createElement(App), node);
var modalParent = document.body.querySelector('.ReactModalPortal').parentNode;
equal(modalParent, document.body);
Expand Down

0 comments on commit a607308

Please sign in to comment.