Skip to content

Commit

Permalink
Release v3.0.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
diasbruno committed Oct 6, 2017
1 parent d0f242b commit a2a7128
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 21 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v2.4.1 - Fri, 06 Oct 2017 12:09:11 UTC
--------------------------------------




v2.4.1 - Fri, 06 Oct 2017 13:23:42 UTC
--------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-modal",
"version": "2.4.1",
"version": "3.0.0",
"homepage": "https://github.com/reactjs/react-modal",
"authors": [
"Ryan Florence",
Expand Down
49 changes: 31 additions & 18 deletions dist/react-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ function totalCount() {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.canUseDOM = undefined;

var _exenv = __webpack_require__(20);

Expand All @@ -503,8 +504,9 @@ var EE = _exenv2.default;

var SafeHTMLElement = EE.canUseDOM ? window.HTMLElement : {};

var canUseDOM = exports.canUseDOM = EE.canUseDOM;

exports.default = SafeHTMLElement;
module.exports = exports['default'];

/***/ }),
/* 10 */
Expand Down Expand Up @@ -579,7 +581,8 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
var portalClassName = exports.portalClassName = 'ReactModalPortal';
var bodyOpenClassName = exports.bodyOpenClassName = 'ReactModal__Body--open';

var renderSubtreeIntoContainer = _reactDom2.default.unstable_renderSubtreeIntoContainer;
var isReact16 = _reactDom2.default.createPortal !== undefined;
var createPortal = isReact16 ? _reactDom2.default.createPortal : _reactDom2.default.unstable_renderSubtreeIntoContainer;

function getParentElement(parentSelector) {
return parentSelector();
Expand All @@ -600,28 +603,36 @@ var Modal = function (_Component) {
}

return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Modal.__proto__ || Object.getPrototypeOf(Modal)).call.apply(_ref, [this].concat(args))), _this), _this.removePortal = function () {
_reactDom2.default.unmountComponentAtNode(_this.node);
!isReact16 && _reactDom2.default.unmountComponentAtNode(_this.node);
var parent = getParentElement(_this.props.parentSelector);
parent.removeChild(_this.node);
}, _this.portalRef = function (ref) {
_this.portal = ref;
}, _this.renderPortal = function (props) {
_this.portal = renderSubtreeIntoContainer(_this, _react2.default.createElement(_ModalPortal2.default, _extends({ defaultStyles: Modal.defaultStyles }, props)), _this.node);
var portal = createPortal(_this, _react2.default.createElement(_ModalPortal2.default, _extends({ defaultStyles: Modal.defaultStyles }, props)), _this.node);
_this.portalRef(portal);
}, _temp), _possibleConstructorReturn(_this, _ret);
}

_createClass(Modal, [{
key: 'componentDidMount',
value: function componentDidMount() {
this.node = document.createElement('div');
if (!_safeHTMLElement.canUseDOM) return;

if (!isReact16) {
this.node = document.createElement('div');
}
this.node.className = this.props.portalClassName;

var parent = getParentElement(this.props.parentSelector);
parent.appendChild(this.node);

this.renderPortal(this.props);
!isReact16 && this.renderPortal(this.props);
}
}, {
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(newProps) {
if (!_safeHTMLElement.canUseDOM) return;
var isOpen = newProps.isOpen;
// Stop unnecessary renders if modal is remaining closed

Expand All @@ -635,19 +646,20 @@ var Modal = function (_Component) {
newParent.appendChild(this.node);
}

this.renderPortal(newProps);
!isReact16 && this.renderPortal(newProps);
}
}, {
key: 'componentWillUpdate',
value: function componentWillUpdate(newProps) {
if (!_safeHTMLElement.canUseDOM) return;
if (newProps.portalClassName !== this.props.portalClassName) {
this.node.className = newProps.portalClassName;
}
}
}, {
key: 'componentWillUnmount',
value: function componentWillUnmount() {
if (!this.node || !this.portal) return;
if (!_safeHTMLElement.canUseDOM || !this.node || !this.portal) return;

var state = this.portal.state;
var now = Date.now();
Expand All @@ -666,23 +678,24 @@ var Modal = function (_Component) {
}, {
key: 'render',
value: function render() {
return null;
if (!_safeHTMLElement.canUseDOM || !isReact16) {
return null;
}

if (!this.node && isReact16) {
this.node = document.createElement('div');
}

return createPortal(_react2.default.createElement(_ModalPortal2.default, _extends({ ref: this.portalRef,
defaultStyles: Modal.defaultStyles
}, this.props)), this.node);
}
}], [{
key: 'setAppElement',
value: function setAppElement(element) {
ariaAppHider.setElement(element);
}

/* eslint-disable no-console */

}, {
key: 'injectCSS',
value: function injectCSS() {
undefined !== "production" && console.warn('React-Modal: injectCSS has been deprecated ' + 'and no longer has any effect. It will be removed in a later version');
}
/* eslint-enable no-console */

/* eslint-disable react/no-unused-prop-types */

/* eslint-enable react/no-unused-prop-types */
Expand Down
Loading

0 comments on commit a2a7128

Please sign in to comment.