20 lines
634 B
JavaScript
20 lines
634 B
JavaScript
|
import { canUseDOM } from './canUseDOM';
|
||
|
/**
|
||
|
* Helper to get the document object. Note that in popup window cases, document
|
||
|
* might be the wrong document, which is why we look at ownerDocument for the
|
||
|
* truth.
|
||
|
*
|
||
|
* @public
|
||
|
*/
|
||
|
export function getDocument(rootElement) {
|
||
|
// eslint-disable-next-line no-restricted-globals
|
||
|
if (!canUseDOM() || typeof document === 'undefined') {
|
||
|
return undefined;
|
||
|
}
|
||
|
else {
|
||
|
var el = rootElement;
|
||
|
// eslint-disable-next-line no-restricted-globals
|
||
|
return el && el.ownerDocument ? el.ownerDocument : document;
|
||
|
}
|
||
|
}
|
||
|
//# sourceMappingURL=getDocument.js.map
|