ssr-window
Advanced tools
Comparing version 1.0.0 to 1.0.1
/** | ||
* SSR Window 1.0.0 | ||
* SSR Window 1.0.1 | ||
* Better handling for window object in SSR environment | ||
@@ -10,82 +10,66 @@ * https://github.com/nolimits4web/ssr-window | ||
* | ||
* Released on: February 10, 2018 | ||
* Released on: July 18, 2018 | ||
*/ | ||
var d; | ||
if (typeof document === 'undefined') { | ||
d = { | ||
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: '' }, | ||
}; | ||
} else { | ||
// eslint-disable-next-line | ||
d = document; | ||
} | ||
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 doc = d; | ||
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 | ||
var w; | ||
if (typeof window === 'undefined') { | ||
w = { | ||
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() {}, | ||
}; | ||
} else { | ||
// eslint-disable-next-line | ||
w = window; | ||
} | ||
var win = w; | ||
export { win as window, doc as document }; |
/** | ||
* SSR Window 1.0.0 | ||
* SSR Window 1.0.1 | ||
* Better handling for window object in SSR environment | ||
@@ -10,3 +10,3 @@ * https://github.com/nolimits4web/ssr-window | ||
* | ||
* Released on: February 10, 2018 | ||
* Released on: July 18, 2018 | ||
*/ | ||
@@ -19,80 +19,64 @@ (function (global, factory) { | ||
var d; | ||
if (typeof document === 'undefined') { | ||
d = { | ||
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: '' }, | ||
}; | ||
} else { | ||
// eslint-disable-next-line | ||
d = document; | ||
} | ||
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 doc = d; | ||
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 | ||
var w; | ||
if (typeof window === 'undefined') { | ||
w = { | ||
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() {}, | ||
}; | ||
} else { | ||
// eslint-disable-next-line | ||
w = window; | ||
} | ||
var win = w; | ||
exports.window = win; | ||
@@ -99,0 +83,0 @@ exports.document = doc; |
/** | ||
* SSR Window 1.0.0 | ||
* SSR Window 1.0.1 | ||
* Better handling for window object in SSR environment | ||
@@ -10,4 +10,4 @@ * https://github.com/nolimits4web/ssr-window | ||
* | ||
* Released on: February 10, 2018 | ||
* Released on: July 18, 2018 | ||
*/!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.ssrWindow={})}(this,function(e){"use strict";var n="undefined"==typeof document?{body:{},addEventListener:function(){},removeEventListener:function(){},activeElement:{blur:function(){},nodeName:""},querySelector:function(){return null},querySelectorAll:function(){return[]},getElementById:function(){return null},createEvent:function(){return{initEvent:function(){}}},createElement:function(){return{children:[],childNodes:[],style:{},setAttribute:function(){},getElementsByTagName:function(){return[]}}},location:{hash:""}}:document,t="undefined"==typeof window?{document:n,navigator:{userAgent:""},location:{},history:{},CustomEvent:function(){return this},addEventListener:function(){},removeEventListener:function(){},getComputedStyle:function(){return{getPropertyValue:function(){return""}}},Image:function(){},Date:function(){},screen:{},setTimeout:function(){},clearTimeout:function(){}}:window;e.window=t,e.document=n,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=ssr-window.min.js.map |
@@ -80,9 +80,9 @@ const gulp = require('gulp'); | ||
}) | ||
.pipe(source('ssr-window.js', './src')) | ||
.pipe(buffer()) | ||
.pipe(rename('ssr-window.esm.js')) | ||
.pipe(gulp.dest(`./${env === 'development' ? 'build' : 'dist'}/`)) | ||
.on('end', () => { | ||
if (cb) cb(); | ||
}); | ||
.pipe(source('ssr-window.js', './src')) | ||
.pipe(buffer()) | ||
.pipe(rename('ssr-window.esm.js')) | ||
.pipe(gulp.dest(`./${env === 'development' ? 'build' : 'dist'}/`)) | ||
.on('end', () => { | ||
if (cb) cb(); | ||
}); | ||
} | ||
@@ -89,0 +89,0 @@ |
{ | ||
"name": "ssr-window", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Better handling for window object in SSR environment", | ||
@@ -5,0 +5,0 @@ "main": "dist/ssr-window.js", |
@@ -1,45 +0,37 @@ | ||
let d; | ||
if (typeof document === 'undefined') { | ||
d = { | ||
body: {}, | ||
addEventListener() {}, | ||
removeEventListener() {}, | ||
activeElement: { | ||
blur() {}, | ||
nodeName: '', | ||
}, | ||
querySelector() { | ||
return null; | ||
}, | ||
querySelectorAll() { | ||
return []; | ||
}, | ||
getElementById() { | ||
return null; | ||
}, | ||
createEvent() { | ||
return { | ||
initEvent() {}, | ||
}; | ||
}, | ||
createElement() { | ||
return { | ||
children: [], | ||
childNodes: [], | ||
style: {}, | ||
setAttribute() {}, | ||
getElementsByTagName() { | ||
return []; | ||
}, | ||
}; | ||
}, | ||
location: { hash: '' }, | ||
}; | ||
} else { | ||
// eslint-disable-next-line | ||
d = document; | ||
} | ||
const doc = (typeof document === 'undefined') ? { | ||
body: {}, | ||
addEventListener() {}, | ||
removeEventListener() {}, | ||
activeElement: { | ||
blur() {}, | ||
nodeName: '', | ||
}, | ||
querySelector() { | ||
return null; | ||
}, | ||
querySelectorAll() { | ||
return []; | ||
}, | ||
getElementById() { | ||
return null; | ||
}, | ||
createEvent() { | ||
return { | ||
initEvent() {}, | ||
}; | ||
}, | ||
createElement() { | ||
return { | ||
children: [], | ||
childNodes: [], | ||
style: {}, | ||
setAttribute() {}, | ||
getElementsByTagName() { | ||
return []; | ||
}, | ||
}; | ||
}, | ||
location: { hash: '' }, | ||
} : document; // eslint-disable-line | ||
const doc = d; | ||
export default doc; |
import document from './document'; | ||
let w; | ||
if (typeof window === 'undefined') { | ||
w = { | ||
document, | ||
navigator: { | ||
userAgent: '', | ||
}, | ||
location: {}, | ||
history: {}, | ||
CustomEvent: function CustomEvent() { | ||
return this; | ||
}, | ||
addEventListener() {}, | ||
removeEventListener() {}, | ||
getComputedStyle() { | ||
return { | ||
getPropertyValue() { | ||
return ''; | ||
}, | ||
}; | ||
}, | ||
Image() {}, | ||
Date() {}, | ||
screen: {}, | ||
setTimeout() {}, | ||
clearTimeout() {}, | ||
}; | ||
} else { | ||
// eslint-disable-next-line | ||
w = window; | ||
} | ||
const win = (typeof window === 'undefined') ? { | ||
document, | ||
navigator: { | ||
userAgent: '', | ||
}, | ||
location: {}, | ||
history: {}, | ||
CustomEvent: function CustomEvent() { | ||
return this; | ||
}, | ||
addEventListener() {}, | ||
removeEventListener() {}, | ||
getComputedStyle() { | ||
return { | ||
getPropertyValue() { | ||
return ''; | ||
}, | ||
}; | ||
}, | ||
Image() {}, | ||
Date() {}, | ||
screen: {}, | ||
setTimeout() {}, | ||
clearTimeout() {}, | ||
} : window; // eslint-disable-line | ||
const win = w; | ||
export default win; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14
16452
358