Moved DOM objects to helper module

This commit is contained in:
Christoph Oberhofer
2016-06-19 17:32:21 +02:00
parent b9efb07456
commit 5231824d98
4 changed files with 34 additions and 13 deletions
+21
View File
@@ -0,0 +1,21 @@
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;