Skip to content

Commit f925347

Browse files
committed
[changed] Get rid of CommonJS module
1 parent b261459 commit f925347

File tree

4 files changed

+15
-20
lines changed

4 files changed

+15
-20
lines changed

lib/components/Modal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import ReactDOM from 'react-dom';
33
import ExecutionEnvironment from 'exenv';
44
import elementClass from 'element-class';
55
import ModalPortal from './ModalPortal';
6-
import ariaAppHider from '../helpers/ariaAppHider';
6+
import * as ariaAppHider from '../helpers/ariaAppHider';
77

88
const renderSubtreeIntoContainer = ReactDOM.unstable_renderSubtreeIntoContainer;
99

lib/helpers/ariaAppHider.js

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
let globalElement = typeof document !== 'undefined' ? document.body : null;
22

3-
function setElement (element) {
3+
function validateElement (appElement) {
4+
if (!appElement && !globalElement) {
5+
throw new Error('react-modal: You must set an element with `Modal.setAppElement(el)` to make this accessible');
6+
}
7+
}
8+
9+
export function setElement (element) {
410
let newElement = element;
511
if (typeof newElement === 'string') {
612
const el = document.querySelectorAll(element);
@@ -10,34 +16,22 @@ function setElement (element) {
1016
return globalElement;
1117
}
1218

13-
function validateElement (appElement) {
14-
if (!appElement && !globalElement) {
15-
throw new Error('react-modal: You must set an element with `Modal.setAppElement(el)` to make this accessible');
16-
}
17-
}
18-
19-
function hide (appElement) {
19+
export function hide (appElement) {
2020
validateElement(appElement);
2121
(appElement || globalElement).setAttribute('aria-hidden', 'true');
2222
}
2323

24-
function show (appElement) {
24+
export function show (appElement) {
2525
validateElement(appElement);
2626
(appElement || globalElement).removeAttribute('aria-hidden');
2727
}
2828

29-
function toggle (shouldHide, appElement) {
29+
export function toggle (shouldHide, appElement) {
3030
if (shouldHide) {
3131
hide(appElement);
3232
} else { show(appElement); }
3333
}
3434

35-
function resetForTesting () {
35+
export function resetForTesting () {
3636
globalElement = document.body;
3737
}
38-
39-
exports.toggle = toggle;
40-
exports.setElement = setElement;
41-
exports.show = show;
42-
exports.hide = hide;
43-
exports.resetForTesting = resetForTesting;

lib/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
module.exports = require('./components/Modal');
1+
import Modal from './components/Modal';
22

3+
export default Modal;

specs/Modal.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import sinon from 'sinon';
1111
import expect from 'expect';
1212
import ReactDOM from 'react-dom';
1313
import Modal from '../lib/components/Modal';
14-
import ariaAppHider from '../lib/helpers/ariaAppHider';
14+
import * as ariaAppHider from '../lib/helpers/ariaAppHider';
1515
import { renderModal, unmountModal } from './helper';
1616

1717
const Simulate = TestUtils.Simulate;

0 commit comments

Comments
 (0)