-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* References to host objects need to be extracted from the global object associated with provided element
- Loading branch information
Showing
3 changed files
with
28 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
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; | ||
}; |