diff --git a/src/components/Modal.js b/src/components/Modal.js index 5a914e4b..bf26683b 100644 --- a/src/components/Modal.js +++ b/src/components/Modal.js @@ -3,15 +3,13 @@ import ReactDOM from 'react-dom'; import PropTypes from 'prop-types'; import ModalPortal from './ModalPortal'; import * as ariaAppHider from '../helpers/ariaAppHider'; -import SafeHTMLElement from '../helpers/safeHTMLElement'; +import SafeHTMLElement, { + canUseDOM +} from '../helpers/safeHTMLElement'; export const portalClassName = 'ReactModalPortal'; export const bodyOpenClassName = 'ReactModal__Body--open'; -const canUseDOM = typeof window !== 'undefined' && - typeof document !== 'undefined' && - typeof document.createElement === 'function'; - const isReact16 = ReactDOM.createPortal !== undefined; const createPortal = isReact16 ? ReactDOM.createPortal : diff --git a/src/helpers/safeHTMLElement.js b/src/helpers/safeHTMLElement.js index 7a8752b0..3798072d 100644 --- a/src/helpers/safeHTMLElement.js +++ b/src/helpers/safeHTMLElement.js @@ -4,4 +4,6 @@ const EE = ExecutionEnvironment; const SafeHTMLElement = EE.canUseDOM ? window.HTMLElement : {}; +export const canUseDOM = EE.canUseDOM; + export default SafeHTMLElement;