You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
443 B
JavaScript
22 lines
443 B
JavaScript
![]()
9 years ago
|
const hasWindow = typeof window !== 'undefined';
|
||
|
const windowRef = hasWindow ? window : {};
|
||
|
|
||
|
const windowObjects = [
|
||
|
"MediaStream",
|
||
|
"HTMLImageElement",
|
||
|
"HTMLVideoElement",
|
||
|
"HTMLCanvasElement",
|
||
|
"FileList",
|
||
|
"File",
|
||
|
"URL"
|
||
|
];
|
||
|
|
||
|
const DOMHelper = windowObjects.reduce((result, obj) => {
|
||
|
return {
|
||
|
...result,
|
||
|
[obj]: obj in windowRef ? windowRef[obj] : () => {}
|
||
|
};
|
||
|
}, {});
|
||
|
|
||
|
export default DOMHelper;
|