File tree Expand file tree Collapse file tree 1 file changed +16
-12
lines changed Expand file tree Collapse file tree 1 file changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -23,26 +23,30 @@ export default class ResizeObserverLite {
2323 this . disconnect ( ) ;
2424 }
2525
26- if ( this . hasResizeObserver ) {
27- this . rz ! . observe ( element ) ;
28- } else {
29- this . erd ! . listenTo ( element , ( element ) => {
30- this . handler ( getSize ( element ) ) ;
31- } ) ;
26+ if ( element ) {
27+ if ( this . hasResizeObserver ) {
28+ this . rz ! . observe ( element ) ;
29+ } else {
30+ this . erd ! . listenTo ( element , ( element ) => {
31+ this . handler ( getSize ( element ) ) ;
32+ } ) ;
33+ }
3234 }
3335
3436 this . listenedElement = element ;
3537 }
3638 }
3739
3840 disconnect ( ) {
39- if ( this . hasResizeObserver ) {
40- this . rz ! . disconnect ( ) ;
41- } else {
42- this . erd ! . uninstall ( this . listenedElement ! ) ;
43- }
41+ if ( this . listenedElement ) {
42+ if ( this . hasResizeObserver ) {
43+ this . rz ! . disconnect ( ) ;
44+ } else {
45+ this . erd ! . uninstall ( this . listenedElement ! ) ;
46+ }
4447
45- this . listenedElement = null ;
48+ this . listenedElement = null ;
49+ }
4650 }
4751}
4852
You can’t perform that action at this time.
0 commit comments