'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.setElement = setElement;
exports.validateElement = validateElement;
exports.hide = hide;
exports.show = show;
exports.toggle = toggle;
exports.resetForTesting = resetForTesting;
var globalElement = typeof document !== 'undefined' ? document.body : null;
function setElement(element) {
var useElement = element;
Iif (typeof useElement === 'string') {
var el = document.querySelectorAll(useElement);
useElement = 'length' in el ? el[0] : el;
}
globalElement = useElement || globalElement;
return globalElement;
}
function validateElement(appElement) {
Iif (!appElement && !globalElement) {
throw new Error(['react-modal: You must set an element with', '`Modal.setAppElement(el)` to make this accessible']);
}
}
function hide(appElement) {
validateElement(appElement);
(appElement || globalElement).setAttribute('aria-hidden', 'true');
}
function show(appElement) {
validateElement(appElement);
(appElement || globalElement).removeAttribute('aria-hidden');
}
function toggle(shouldHide, appElement) {
var apply = shouldHide ? hide : show;
apply(appElement);
}
function resetForTesting() {
globalElement = document.body;
}
|