chushihua
This commit is contained in:
+74
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* SSR Window 1.0.1
|
||||
* Better handling for window object in SSR environment
|
||||
* https://github.com/nolimits4web/ssr-window
|
||||
*
|
||||
* Copyright 2018, Vladimir Kharlampidi
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
* Released on: July 18, 2018
|
||||
*/
|
||||
var doc = (typeof document === 'undefined') ? {
|
||||
body: {},
|
||||
addEventListener: function addEventListener() {},
|
||||
removeEventListener: function removeEventListener() {},
|
||||
activeElement: {
|
||||
blur: function blur() {},
|
||||
nodeName: '',
|
||||
},
|
||||
querySelector: function querySelector() {
|
||||
return null;
|
||||
},
|
||||
querySelectorAll: function querySelectorAll() {
|
||||
return [];
|
||||
},
|
||||
getElementById: function getElementById() {
|
||||
return null;
|
||||
},
|
||||
createEvent: function createEvent() {
|
||||
return {
|
||||
initEvent: function initEvent() {},
|
||||
};
|
||||
},
|
||||
createElement: function createElement() {
|
||||
return {
|
||||
children: [],
|
||||
childNodes: [],
|
||||
style: {},
|
||||
setAttribute: function setAttribute() {},
|
||||
getElementsByTagName: function getElementsByTagName() {
|
||||
return [];
|
||||
},
|
||||
};
|
||||
},
|
||||
location: { hash: '' },
|
||||
} : document; // eslint-disable-line
|
||||
|
||||
var win = (typeof window === 'undefined') ? {
|
||||
document: doc,
|
||||
navigator: {
|
||||
userAgent: '',
|
||||
},
|
||||
location: {},
|
||||
history: {},
|
||||
CustomEvent: function CustomEvent() {
|
||||
return this;
|
||||
},
|
||||
addEventListener: function addEventListener() {},
|
||||
removeEventListener: function removeEventListener() {},
|
||||
getComputedStyle: function getComputedStyle() {
|
||||
return {
|
||||
getPropertyValue: function getPropertyValue() {
|
||||
return '';
|
||||
},
|
||||
};
|
||||
},
|
||||
Image: function Image() {},
|
||||
Date: function Date() {},
|
||||
screen: {},
|
||||
setTimeout: function setTimeout() {},
|
||||
clearTimeout: function clearTimeout() {},
|
||||
} : window; // eslint-disable-line
|
||||
|
||||
export { win as window, doc as document };
|
||||
Reference in New Issue
Block a user