mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-24 21:15:06 +08:00
19 lines
601 B
JavaScript
19 lines
601 B
JavaScript
|
|
import global from '../shims/global.js';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Returns the global object associated with provided element.
|
||
|
|
*
|
||
|
|
* @param {Object} target
|
||
|
|
* @returns {Object}
|
||
|
|
*/
|
||
|
|
export default target => {
|
||
|
|
// Assume that the element is an instance of Node, which means that it
|
||
|
|
// has the "ownerDocument" property from which we can retrieve a
|
||
|
|
// corresponding global object.
|
||
|
|
const ownerGlobal = target && target.ownerDocument && target.ownerDocument.defaultView;
|
||
|
|
|
||
|
|
// Return the local global object if it's not possible extract one from
|
||
|
|
// provided element.
|
||
|
|
return ownerGlobal || global;
|
||
|
|
};
|