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 {
23
23
this . disconnect ( ) ;
24
24
}
25
25
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
+ }
32
34
}
33
35
34
36
this . listenedElement = element ;
35
37
}
36
38
}
37
39
38
40
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
+ }
44
47
45
- this . listenedElement = null ;
48
+ this . listenedElement = null ;
49
+ }
46
50
}
47
51
}
48
52
You can’t perform that action at this time.
0 commit comments