UNPKG

@uifabric/utilities

Version:

Fluent UI React utilities for building components.

1 lines 1.08 kB
{"version":3,"file":"getDocument.js","sourceRoot":"../src/","sources":["dom/getDocument.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,WAAgC;IAC1D,IAAI,MAAM,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;QAC7C,OAAO,SAAS,CAAC;KAClB;SAAM;QACL,IAAM,EAAE,GAAG,WAAsB,CAAC;QAElC,OAAO,EAAE,IAAI,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC;KAC7D;AACH,CAAC","sourcesContent":["import { _isSSR } from './setSSR';\n\n/**\n * Helper to get the document object. Note that in popup window cases, document\n * might be the wrong document, which is why we look at ownerDocument for the\n * truth. Also note that the SSR flag is used to test ssr scenarios even if\n * document is defined (from JSDOM for example.)\n *\n * @public\n */\nexport function getDocument(rootElement?: HTMLElement | null): Document | undefined {\n if (_isSSR || typeof document === 'undefined') {\n return undefined;\n } else {\n const el = rootElement as Element;\n\n return el && el.ownerDocument ? el.ownerDocument : document;\n }\n}\n"]}