From 27579ca1c216b3691926790ecacf0c65a4acc9be Mon Sep 17 00:00:00 2001 From: Bruno Dias Date: Sun, 25 Jun 2017 17:44:29 -0300 Subject: [PATCH] Release v2.0.7. --- CHANGELOG.md | 11 +++++++++++ bower.json | 2 +- dist/react-modal.js | 34 +++++++++++++++++++++++++++------- dist/react-modal.min.js | 4 ++-- package.json | 2 +- 5 files changed, 42 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f934e33..f586af73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +v2.0.7 - Sun, 25 Jun 2017 17:43:35 UTC +-------------------------------------- + +- [bb69a91](../../commit/bb69a91) [chore] improvements on readme testing section. +- [c2f582f](../../commit/c2f582f) [chore] fix typo. +- [f8edc2b](../../commit/f8edc2b) [fixed] improvements on setAppElement... +- [5641f40](../../commit/5641f40) [chore] update installation section. +- [ae258ec](../../commit/ae258ec) [chore] removing active development section. +- [f5d95e2](../../commit/f5d95e2) Add codesandbox link to the ISSUE_TEMPLATE + + v2.0.6 - Tue, 20 Jun 2017 11:22:57 UTC -------------------------------------- diff --git a/bower.json b/bower.json index 5808da3f..57c39a98 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "react-modal", - "version": "2.0.6", + "version": "2.0.7", "homepage": "https://github.com/reactjs/react-modal", "authors": [ "Ryan Florence", diff --git a/dist/react-modal.js b/dist/react-modal.js index 1127ae98..226a5cf6 100644 --- a/dist/react-modal.js +++ b/dist/react-modal.js @@ -128,9 +128,6 @@ return /******/ (function(modules) { // webpackBootstrap var renderSubtreeIntoContainer = _reactDom2.default.unstable_renderSubtreeIntoContainer; var SafeHTMLElement = EE.canUseDOM ? window.HTMLElement : {}; - var AppElement = EE.canUseDOM ? document.body : { - appendChild: function appendChild() {} - }; function getParentElement(parentSelector) { return parentSelector(); @@ -249,7 +246,7 @@ return /******/ (function(modules) { // webpackBootstrap }], [{ key: 'setAppElement', value: function setAppElement(element) { - ariaAppHider.setElement(element || AppElement); + ariaAppHider.setElement(element); } /* eslint-disable no-console */ @@ -1809,27 +1806,46 @@ return /******/ (function(modules) { // webpackBootstrap Object.defineProperty(exports, "__esModule", { value: true }); + exports.assertNodeList = assertNodeList; exports.setElement = setElement; + exports.tryForceFallback = tryForceFallback; exports.validateElement = validateElement; exports.hide = hide; exports.show = show; exports.toggle = toggle; + exports.documentNotReadyOrSSRTesting = documentNotReadyOrSSRTesting; exports.resetForTesting = resetForTesting; - var globalElement = typeof document !== 'undefined' ? document.body : null; + var globalElement = null; + + function assertNodeList(nodeList, selector) { + if (!nodeList || !nodeList.length) { + throw new Error('react-modal: No elements were found for selector ' + selector + '.'); + } + } function setElement(element) { var useElement = element; if (typeof useElement === 'string') { var el = document.querySelectorAll(useElement); + assertNodeList(el, useElement); useElement = 'length' in el ? el[0] : el; } globalElement = useElement || globalElement; return globalElement; } + function tryForceFallback() { + if (document && document.body) { + // force fallback to document.body + setElement(document.body); + return true; + } + return false; + } + function validateElement(appElement) { - if (!appElement && !globalElement) { - throw new Error(['react-modal: You must set an element with', '`Modal.setAppElement(el)` to make this accessible']); + if (!appElement && !globalElement && !tryForceFallback()) { + throw new Error(['react-modal: Cannot fallback to `document.body`, because it\'s not ready or available.', 'If you are doing server-side rendering, use this function to defined an element.', '`Modal.setAppElement(el)` to make this accessible']); } } @@ -1848,6 +1864,10 @@ return /******/ (function(modules) { // webpackBootstrap apply(appElement); } + function documentNotReadyOrSSRTesting() { + globalElement = null; + } + function resetForTesting() { globalElement = document.body; } diff --git a/dist/react-modal.min.js b/dist/react-modal.min.js index 34e025b5..ecc7e65f 100644 --- a/dist/react-modal.min.js +++ b/dist/react-modal.min.js @@ -1,4 +1,4 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","react-dom"],t):"object"==typeof exports?exports.ReactModal=t(require("react"),require("react-dom")):e.ReactModal=t(e.React,e.ReactDOM)}(this,function(e,t){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return e[o].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="/",t(0)}([function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var r=n(1),a=o(r);t.default=a.default},function(e,t,n){"use strict";function o(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function r(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function u(e){return e()}Object.defineProperty(t,"__esModule",{value:!0});var l=Object.assign||function(e){for(var t=1;t0?(0,w.default)(document.body).add(o.props.bodyOpenClassName):(0,w.default)(document.body).remove(o.props.bodyOpenClassName),e.ariaHideApp&&P.toggle(e.isOpen,e.appElement),o.portal=x(o,p.default.createElement(C.default,l({defaultStyles:t.defaultStyles},e)),o.node)},r=n,i(o,r)}return s(t,e),c(t,[{key:"componentDidMount",value:function(){this.node=document.createElement("div"),this.node.className=this.props.portalClassName,this.props.isOpen&&_.add(this);var e=u(this.props.parentSelector);e.appendChild(this.node),this.renderPortal(this.props)}},{key:"componentWillReceiveProps",value:function(e){var t=e.isOpen;if(this.props.isOpen||t){t&&_.add(this),t||_.remove(this);var n=u(this.props.parentSelector),o=u(e.parentSelector);o!==n&&(n.removeChild(this.node),o.appendChild(this.node)),this.renderPortal(e)}}},{key:"componentWillUpdate",value:function(e){e.portalClassName!==this.props.portalClassName&&(this.node.className=e.portalClassName)}},{key:"componentWillUnmount",value:function(){var e=this;if(this.node){_.remove(this),this.props.ariaHideApp&&P.show(this.props.appElement);var t=this.portal.state,n=Date.now(),o=t.isOpen&&this.props.closeTimeoutMS&&(t.closesAt||n+this.props.closeTimeoutMS);o?(t.beforeClose||this.portal.closeWithTimeout(),setTimeout(function(){return e.removePortal},o-n)):this.removePortal()}}},{key:"render",value:function(){return null}}],[{key:"setAppElement",value:function(e){P.setElement(e||R)}},{key:"injectCSS",value:function(){console.warn("React-Modal: injectCSS has been deprecated and no longer has any effect. It will be removed in a later version")}}]),t}(f.Component);k.propTypes={isOpen:h.default.bool.isRequired,style:h.default.shape({content:h.default.object,overlay:h.default.object}),portalClassName:h.default.string,bodyOpenClassName:h.default.string,className:h.default.oneOfType([h.default.string,h.default.object]),overlayClassName:h.default.oneOfType([h.default.string,h.default.object]),appElement:h.default.instanceOf(S),onAfterOpen:h.default.func,onRequestClose:h.default.func,closeTimeoutMS:h.default.number,ariaHideApp:h.default.bool,shouldCloseOnOverlayClick:h.default.bool,parentSelector:h.default.func,role:h.default.string,contentLabel:h.default.string.isRequired},k.defaultProps={isOpen:!1,portalClassName:"ReactModalPortal",bodyOpenClassName:"ReactModal__Body--open",ariaHideApp:!0,closeTimeoutMS:0,shouldCloseOnOverlayClick:!0,parentSelector:function(){return document.body}},k.defaultStyles={overlay:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(255, 255, 255, 0.75)"},content:{position:"absolute",top:"40px",left:"40px",right:"40px",bottom:"40px",border:"1px solid #ccc",background:"#fff",overflow:"auto",WebkitOverflowScrolling:"touch",borderRadius:"4px",outline:"none",padding:"20px"}},t.default=k},function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t,n){var o="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,r=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===o},a=!0;e.exports=n(5)(r,a)},function(e,t,n){"use strict";var o=n(6),r=n(7),a=n(8),i=n(9),s=n(10);e.exports=function(e,t){function n(e){var t=e&&(E&&e[E]||e[x]);if("function"==typeof t)return t}function u(e,t){return e===t?0!==e||1/e===1/t:e!==e&&t!==t}function l(e){this.message=e,this.stack=""}function c(e){function n(n,u,c,f,p,d,y){if(f=f||S,d=d||c,y!==i)if(t)r(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");else if("undefined"!=typeof console){var v=f+":"+c;!o[v]&&s<3&&(a(!1,"You are manually calling a React.PropTypes validation function for the `%s` prop on `%s`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.",d,f),o[v]=!0,s++)}return null==u[c]?n?new l(null===u[c]?"The "+p+" `"+d+"` is marked as required "+("in `"+f+"`, but its value is `null`."):"The "+p+" `"+d+"` is marked as required in "+("`"+f+"`, but its value is `undefined`.")):null:e(u,c,f,p,d)}var o={},s=0,u=n.bind(null,!1);return u.isRequired=n.bind(null,!0),u}function f(e){function t(t,n,o,r,a,i){var s=t[n],u=T(s);if(u!==e){var c=P(s);return new l("Invalid "+r+" `"+a+"` of type "+("`"+c+"` supplied to `"+o+"`, expected ")+("`"+e+"`."))}return null}return c(t)}function p(){return c(o.thatReturnsNull)}function d(e){function t(t,n,o,r,a){if("function"!=typeof e)return new l("Property `"+a+"` of component `"+o+"` has invalid PropType notation inside arrayOf.");var s=t[n];if(!Array.isArray(s)){var u=T(s);return new l("Invalid "+r+" `"+a+"` of type "+("`"+u+"` supplied to `"+o+"`, expected an array."))}for(var c=0;c1?t-1:0),o=1;o2?o-2:0),a=2;a0?(0,w.default)(document.body).add(o.props.bodyOpenClassName):(0,w.default)(document.body).remove(o.props.bodyOpenClassName),e.ariaHideApp&&P.toggle(e.isOpen,e.appElement),o.portal=S(o,p.default.createElement(C.default,l({defaultStyles:t.defaultStyles},e)),o.node)},r=n,i(o,r)}return s(t,e),c(t,[{key:"componentDidMount",value:function(){this.node=document.createElement("div"),this.node.className=this.props.portalClassName,this.props.isOpen&&_.add(this);var e=u(this.props.parentSelector);e.appendChild(this.node),this.renderPortal(this.props)}},{key:"componentWillReceiveProps",value:function(e){var t=e.isOpen;if(this.props.isOpen||t){t&&_.add(this),t||_.remove(this);var n=u(this.props.parentSelector),o=u(e.parentSelector);o!==n&&(n.removeChild(this.node),o.appendChild(this.node)),this.renderPortal(e)}}},{key:"componentWillUpdate",value:function(e){e.portalClassName!==this.props.portalClassName&&(this.node.className=e.portalClassName)}},{key:"componentWillUnmount",value:function(){var e=this;if(this.node){_.remove(this),this.props.ariaHideApp&&P.show(this.props.appElement);var t=this.portal.state,n=Date.now(),o=t.isOpen&&this.props.closeTimeoutMS&&(t.closesAt||n+this.props.closeTimeoutMS);o?(t.beforeClose||this.portal.closeWithTimeout(),setTimeout(function(){return e.removePortal},o-n)):this.removePortal()}}},{key:"render",value:function(){return null}}],[{key:"setAppElement",value:function(e){P.setElement(e)}},{key:"injectCSS",value:function(){console.warn("React-Modal: injectCSS has been deprecated and no longer has any effect. It will be removed in a later version")}}]),t}(f.Component);R.propTypes={isOpen:h.default.bool.isRequired,style:h.default.shape({content:h.default.object,overlay:h.default.object}),portalClassName:h.default.string,bodyOpenClassName:h.default.string,className:h.default.oneOfType([h.default.string,h.default.object]),overlayClassName:h.default.oneOfType([h.default.string,h.default.object]),appElement:h.default.instanceOf(x),onAfterOpen:h.default.func,onRequestClose:h.default.func,closeTimeoutMS:h.default.number,ariaHideApp:h.default.bool,shouldCloseOnOverlayClick:h.default.bool,parentSelector:h.default.func,role:h.default.string,contentLabel:h.default.string.isRequired},R.defaultProps={isOpen:!1,portalClassName:"ReactModalPortal",bodyOpenClassName:"ReactModal__Body--open",ariaHideApp:!0,closeTimeoutMS:0,shouldCloseOnOverlayClick:!0,parentSelector:function(){return document.body}},R.defaultStyles={overlay:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(255, 255, 255, 0.75)"},content:{position:"absolute",top:"40px",left:"40px",right:"40px",bottom:"40px",border:"1px solid #ccc",background:"#fff",overflow:"auto",WebkitOverflowScrolling:"touch",borderRadius:"4px",outline:"none",padding:"20px"}},t.default=R},function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t,n){var o="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,r=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===o},a=!0;e.exports=n(5)(r,a)},function(e,t,n){"use strict";var o=n(6),r=n(7),a=n(8),i=n(9),s=n(10);e.exports=function(e,t){function n(e){var t=e&&(E&&e[E]||e[S]);if("function"==typeof t)return t}function u(e,t){return e===t?0!==e||1/e===1/t:e!==e&&t!==t}function l(e){this.message=e,this.stack=""}function c(e){function n(n,u,c,f,p,d,y){if(f=f||x,d=d||c,y!==i)if(t)r(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");else if("undefined"!=typeof console){var v=f+":"+c;!o[v]&&s<3&&(a(!1,"You are manually calling a React.PropTypes validation function for the `%s` prop on `%s`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.",d,f),o[v]=!0,s++)}return null==u[c]?n?new l(null===u[c]?"The "+p+" `"+d+"` is marked as required "+("in `"+f+"`, but its value is `null`."):"The "+p+" `"+d+"` is marked as required in "+("`"+f+"`, but its value is `undefined`.")):null:e(u,c,f,p,d)}var o={},s=0,u=n.bind(null,!1);return u.isRequired=n.bind(null,!0),u}function f(e){function t(t,n,o,r,a,i){var s=t[n],u=T(s);if(u!==e){var c=P(s);return new l("Invalid "+r+" `"+a+"` of type "+("`"+c+"` supplied to `"+o+"`, expected ")+("`"+e+"`."))}return null}return c(t)}function p(){return c(o.thatReturnsNull)}function d(e){function t(t,n,o,r,a){if("function"!=typeof e)return new l("Property `"+a+"` of component `"+o+"` has invalid PropType notation inside arrayOf.");var s=t[n];if(!Array.isArray(s)){var u=T(s);return new l("Invalid "+r+" `"+a+"` of type "+("`"+u+"` supplied to `"+o+"`, expected an array."))}for(var c=0;c1?t-1:0),o=1;o2?o-2:0),a=2;a