11import { parseRootMargin , shallowCompareOptions } from './utils' ;
22
3+ export const storage = new Map ( ) ;
4+
35export function getPooled ( options = { } ) {
46 const root = options . root || null ;
57 const rootMargin = parseRootMargin ( options . rootMargin ) ;
68 const threshold = Array . isArray ( options . threshold )
79 ? options . threshold
810 : [ typeof options . threshold !== 'undefined' ? options . threshold : 0 ] ;
9- // eslint-disable-next-line no-restricted-syntax
10- for ( const observer of storage . keys ( ) ) {
11+ const observers = storage . keys ( ) ;
12+ let observer ;
13+ while ( ( observer = observers . next ( ) . value ) ) {
1114 const unmatched = [
1215 [ root , observer . root ] ,
1316 [ rootMargin , observer . rootMargin ] ,
@@ -21,8 +24,6 @@ export function getPooled(options = {}) {
2124 return null ;
2225}
2326
24- export const storage = new Map ( ) ;
25-
2627/**
2728 * If instances of a class can be reused because the options map,
2829 * we avoid creating instances of Intersection Observer by reusing them.
@@ -35,8 +36,9 @@ export default class IntersectionObserverContainer {
3536 static findElement ( entry , observer ) {
3637 const elements = storage . get ( observer ) ;
3738 if ( elements ) {
38- // eslint-disable-next-line no-restricted-syntax
39- for ( const element of elements . values ( ) ) {
39+ const values = elements . values ( ) ;
40+ let element ;
41+ while ( ( element = values . next ( ) . value ) ) {
4042 if ( element . target === entry . target ) {
4143 return element ;
4244 }
0 commit comments