47de16f2a5c1d84f602ae67c003e3f28235999981d5cb4c2bae7e629039ab48c354120fa0626b39ad3c0c3b5b726dce97f4b76a16ac7221ae1892b9333b1e7 619 B

123456789101112131415161718
  1. import global from '../shims/global.js';
  2. /**
  3. * Returns the global object associated with provided element.
  4. *
  5. * @param {Object} target
  6. * @returns {Object}
  7. */
  8. export default target => {
  9. // Assume that the element is an instance of Node, which means that it
  10. // has the "ownerDocument" property from which we can retrieve a
  11. // corresponding global object.
  12. const ownerGlobal = target && target.ownerDocument && target.ownerDocument.defaultView;
  13. // Return the local global object if it's not possible extract one from
  14. // provided element.
  15. return ownerGlobal || global;
  16. };