You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
420 B

2 months ago
  1. // @flow
  2. import { isElement } from './instanceOf';
  3. import type { Window } from '../types';
  4. export default function getDocumentElement(
  5. element: Element | Window
  6. ): HTMLElement {
  7. // $FlowFixMe[incompatible-return]: assume body is always available
  8. return (
  9. (isElement(element)
  10. ? element.ownerDocument
  11. : // $FlowFixMe[prop-missing]
  12. element.document) || window.document
  13. ).documentElement;
  14. }