MCPcopy
hub / github.com/ampproject/amphtml / setObservation_

Method setObservation_

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

* @param {!Element} target * @param {number} index * @param {?boolean} value * @param {?Array<!ObserverCallbackDef>} callbacks * @private

(target, index, value, callbacks)

Source from the content-addressed store, hash-verified

376 * @private
377 */
378 setObservation_(target, index, value, callbacks) {
379 let observations = this.targetObservations_.get(target);
380 if (!observations) {
381 const observers = this.observers_;
382 observations = new Array(observers.length);
383 for (let i = 0; i < observers.length; i++) {
384 observations[i] = observers[i].io ? null : false;
385 }
386 this.targetObservations_.set(target, observations);
387 }
388
389 if (callbacks) {
390 const oldDisplay = computeDisplay(observations, this.isDocDisplay_);
391 observations[index] = value;
392 const newDisplay = computeDisplay(observations, this.isDocDisplay_);
393 notifyIfChanged(callbacks, target, newDisplay, oldDisplay);
394 } else {
395 observations[index] = value;
396 }
397 }
398}
399
400/**

Callers 4

registerContainerMethod · 0.95
observeMethod · 0.95
containerObserved_Method · 0.95
observed_Method · 0.95

Calls 4

computeDisplayFunction · 0.85
notifyIfChangedFunction · 0.85
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected