* @param {!Element} container * @param {?Element=} opt_root
(container, opt_root)
| 176 | * @param {?Element=} opt_root |
| 177 | */ |
| 178 | registerContainer(container, opt_root) { |
| 179 | const existing = findObserverByContainer(this.observers_, container); |
| 180 | if (existing != -1) { |
| 181 | return; |
| 182 | } |
| 183 | |
| 184 | /** @type {!ObserverDef} */ |
| 185 | const observer = { |
| 186 | container, |
| 187 | root: opt_root || container, |
| 188 | contains: (target) => containsNotSelf(container, target), |
| 189 | // Start with null as IntersectionObserver. Will be initialized when |
| 190 | // the container itself becomes displayed. |
| 191 | io: null, |
| 192 | }; |
| 193 | const index = this.observers_.length; |
| 194 | this.observers_.push(observer); |
| 195 | this.observe(container, this.containerObserved_); |
| 196 | |
| 197 | this.targetObserverCallbacks_.forEach((_, target) => { |
| 198 | // Reset observation to `null` and wait for the actual measurement. |
| 199 | const value = observer.contains(target) ? null : false; |
| 200 | this.setObservation_(target, index, value, /* callbacks */ null); |
| 201 | }); |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * @param {!Element} container |
no test coverage detected