main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
619 bytes
|
Line | |
---|
1 | import global from '../shims/global.js';
|
---|
2 |
|
---|
3 | /**
|
---|
4 | * Returns the global object associated with provided element.
|
---|
5 | *
|
---|
6 | * @param {Object} target
|
---|
7 | * @returns {Object}
|
---|
8 | */
|
---|
9 | export default target => {
|
---|
10 | // Assume that the element is an instance of Node, which means that it
|
---|
11 | // has the "ownerDocument" property from which we can retrieve a
|
---|
12 | // corresponding global object.
|
---|
13 | const ownerGlobal = target && target.ownerDocument && target.ownerDocument.defaultView;
|
---|
14 |
|
---|
15 | // Return the local global object if it's not possible extract one from
|
---|
16 | // provided element.
|
---|
17 | return ownerGlobal || global;
|
---|
18 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.