MCPcopy Create free account
hub / github.com/ampproject/amphtml / unregisterContainer

Method unregisterContainer

src/utils/display-observer.js:207–235  ·  view source on GitHub ↗

* @param {!Element} container

(container)

Source from the content-addressed store, hash-verified

205 * @param {!Element} container
206 */
207 unregisterContainer(container) {
208 const index = findObserverByContainer(this.observers_, container);
209 if (index < CUSTOM_CONTAINER_OFFSET) {
210 // The container has been unregistered already.
211 return;
212 }
213
214 // Remove observer.
215 const observer = this.observers_[index];
216 this.observers_.splice(index, 1);
217 if (observer.io) {
218 observer.io.disconnect();
219 }
220
221 // Unobserve the container itself.
222 this.unobserve(container, this.containerObserved_);
223
224 // Remove observations.
225 this.targetObserverCallbacks_.forEach((callbacks, target) => {
226 const observations = this.targetObservations_.get(target);
227 if (!observations || observations.length <= index) {
228 return;
229 }
230 const oldDisplay = computeDisplay(observations, this.isDocDisplay_);
231 observations.splice(index, 1);
232 const newDisplay = computeDisplay(observations, this.isDocDisplay_);
233 notifyIfChanged(callbacks, target, newDisplay, oldDisplay);
234 });
235 }
236
237 /**
238 * @param {!Element} target

Callers 1

unregisterContainerFunction · 0.80

Calls 7

unobserveMethod · 0.95
findObserverByContainerFunction · 0.85
computeDisplayFunction · 0.85
notifyIfChangedFunction · 0.85
disconnectMethod · 0.45
forEachMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected