| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- /**
- * 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 };
|