File tree 1 file changed +11
-2
lines changed
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import scroll from 'scroll';
2
2
import scrollParent from 'scrollparent' ;
3
3
4
4
export function canUseDOM ( ) {
5
- return ! ! ( typeof window !== 'undefined' && window . document && window . document . createElement ) ;
5
+ return ! ! ( typeof window !== 'undefined' && window . document ? .createElement ) ;
6
6
}
7
7
8
8
/**
@@ -57,7 +57,16 @@ export function getDocumentHeight(median = true): number {
57
57
*/
58
58
export function getElement ( element : string | HTMLElement ) : HTMLElement | null {
59
59
if ( typeof element === 'string' ) {
60
- return document . querySelector ( element ) ;
60
+ try {
61
+ return document . querySelector ( element ) ;
62
+ } catch ( error : any ) {
63
+ if ( process . env . NODE_ENV !== 'production' ) {
64
+ // eslint-disable-next-line no-console
65
+ console . error ( error ) ;
66
+ }
67
+
68
+ return null ;
69
+ }
61
70
}
62
71
63
72
return element ;
You can’t perform that action at this time.
0 commit comments