diff --git a/specs/Modal.spec.js b/specs/Modal.spec.js
index d96196f1..ff8d7056 100644
--- a/specs/Modal.spec.js
+++ b/specs/Modal.spec.js
@@ -84,6 +84,28 @@ export default () => {
ReactDOM.unmountComponentAtNode(node);
});
+ it("allow setting appElement of type string", () => {
+ const node = document.createElement("div");
+ class App extends Component {
+ render() {
+ return (
+
+
+ hello
+
+
+ );
+ }
+ }
+ const appElement = "body";
+ Modal.setAppElement(appElement);
+ ReactDOM.render(, node);
+ document.body
+ .querySelector(".ReactModalPortal")
+ .parentNode.should.be.eql(document.body);
+ ReactDOM.unmountComponentAtNode(node);
+ });
+
it("default parentSelector should be document.body.", () => {
const modal = renderModal({ isOpen: true });
modal.props.parentSelector().should.be.eql(document.body);
diff --git a/src/helpers/ariaAppHider.js b/src/helpers/ariaAppHider.js
index 36d02e77..017b17db 100644
--- a/src/helpers/ariaAppHider.js
+++ b/src/helpers/ariaAppHider.js
@@ -1,4 +1,5 @@
import warning from "warning";
+import { canUseDOM } from "./safeHTMLElement";
let globalElement = null;
@@ -12,7 +13,7 @@ export function assertNodeList(nodeList, selector) {
export function setElement(element) {
let useElement = element;
- if (typeof useElement === "string") {
+ if (typeof useElement === "string" && canUseDOM) {
const el = document.querySelectorAll(useElement);
assertNodeList(el, useElement);
useElement = "length" in el ? el[0] : el;