Skip to content

Commit dd93eff

Browse files
committed
🌀
1 parent f847a63 commit dd93eff

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

dist/show-js-error.esm.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! show-js-error | © 2023 Denis Seleznev | MIT License | https://github.com/hcodes/show-js-error/ */
1+
/*! show-js-error | © 2024 Denis Seleznev | MIT License | https://github.com/hcodes/show-js-error/ */
22
function getScreenSize() {
33
return [screen.width, screen.height, screen.colorDepth].join('×');
44
}
@@ -134,6 +134,9 @@ class ShowJSError {
134134
}
135135
};
136136
this.settings = this.prepareSettings();
137+
if (typeof window === 'undefined') {
138+
return;
139+
}
137140
window.addEventListener('error', this.onerror, false);
138141
window.addEventListener('unhandledrejection', this.onunhandledrejection, false);
139142
document.addEventListener('securitypolicyviolation', this.onsecuritypolicyviolation, false);
@@ -454,6 +457,8 @@ class ShowJSError {
454457
}
455458

456459
const showJSError = new ShowJSError();
457-
window.showJSError = showJSError;
460+
if (typeof window !== 'undefined') {
461+
window.showJSError = showJSError;
462+
}
458463

459464
export { showJSError };

dist/show-js-error.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! show-js-error | © 2023 Denis Seleznev | MIT License | https://github.com/hcodes/show-js-error/ */
1+
/*! show-js-error | © 2024 Denis Seleznev | MIT License | https://github.com/hcodes/show-js-error/ */
22
(function (exports) {
33
'use strict';
44

@@ -138,6 +138,9 @@
138138
}
139139
};
140140
this.settings = this.prepareSettings();
141+
if (typeof window === 'undefined') {
142+
return;
143+
}
141144
window.addEventListener('error', this.onerror, false);
142145
window.addEventListener('unhandledrejection', this.onunhandledrejection, false);
143146
document.addEventListener('securitypolicyviolation', this.onsecuritypolicyviolation, false);
@@ -462,7 +465,9 @@
462465
}());
463466

464467
var showJSError = new ShowJSError();
465-
window.showJSError = showJSError;
468+
if (typeof window !== 'undefined') {
469+
window.showJSError = showJSError;
470+
}
466471

467472
exports.showJSError = showJSError;
468473

0 commit comments

Comments
 (0)