File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -4,12 +4,20 @@ import { debounce } from "radashi"
44
55const resize = {
66 event : new Event ( 'resize' ) ,
7- observer : new ResizeObserver ( ( entries ) =>
8- entries . forEach ( ( entry ) => entry . target . dispatchEvent ( resize . event ) )
9- ) ,
7+ observer : new ResizeObserver ( ( entries ) => {
8+ entries . forEach ( ( entry ) => {
9+ entry . target . dispatchEvent ( resize . event )
10+ } )
11+ } ) ,
12+ listeners : new WeakMap < Element , ( event : Event ) => void > ( ) ,
1013 observe : ( el : Element , func : ( ) => void ) => {
11- resize . observer . observe ( el )
12- el . addEventListener ( 'resize' , func )
14+ if ( ! ( el instanceof Element ) || typeof func !== "function" ) return
15+
16+ if ( ! resize . listeners . has ( el ) ) {
17+ resize . listeners . set ( el , func )
18+ el . addEventListener ( "resize" , func )
19+ resize . observer . observe ( el )
20+ }
1321 } ,
1422}
1523
You can’t perform that action at this time.
0 commit comments