File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 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/ */
22function 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
456459const showJSError = new ShowJSError ( ) ;
457- window . showJSError = showJSError ;
460+ if ( typeof window !== 'undefined' ) {
461+ window . showJSError = showJSError ;
462+ }
458463
459464export { showJSError } ;
Original file line number Diff line number Diff line change 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
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 ) ;
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
You can’t perform that action at this time.
0 commit comments