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

Method scanElement_

extensions/amp-bind/0.1/bind-impl.js:938–958  ·  view source on GitHub ↗

* Scans the element for bindings and adds up to |quota| to `outBindings`. * Also updates ivars `boundElements_` and `expressionToElements_`. * @param {!Element} element * @param {number} quota * @param {!Array<!BindBindingDef>} outBindings * @return {boolean} Returns true if `element`

(element, quota, outBindings)

Source from the content-addressed store, hash-verified

936 * bindings. Otherwise, returns false.
937 */
938 scanElement_(element, quota, outBindings) {
939 let quotaExceeded = false;
940 const boundProperties = this.boundPropertiesInElement_(element);
941 if (boundProperties.length > quota) {
942 boundProperties.length = quota;
943 quotaExceeded = true;
944 }
945 if (boundProperties.length > 0) {
946 this.boundElements_.push({element, boundProperties});
947 }
948 const {tagName} = element;
949 boundProperties.forEach((boundProperty) => {
950 const {expressionString, property} = boundProperty;
951 outBindings.push({tagName, property, expressionString});
952 if (!this.expressionToElements_[expressionString]) {
953 this.expressionToElements_[expressionString] = [];
954 }
955 this.expressionToElements_[expressionString].push(element);
956 });
957 return quotaExceeded;
958 }
959
960 /**
961 * Returns bound properties for an element.

Callers 2

fastScan_Method · 0.95
scanNextNode_Method · 0.95

Calls 3

pushMethod · 0.45
forEachMethod · 0.45

Tested by

no test coverage detected