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

Function forEachContained

src/core/context/node.js:503–517  ·  view source on GitHub ↗

* Iterates over all context nodes that are contained within the specified * `node`. Only iterates over known context nodes. * * @param {Node} node * @param {function(ContextNode<?>):void} callback * @param {boolean=} includeSelf

(node, callback, includeSelf = true)

Source from the content-addressed store, hash-verified

501 * @param {boolean=} includeSelf
502 */
503function forEachContained(node, callback, includeSelf = true) {
504 const closest = ContextNode.closest(node, includeSelf);
505 if (!closest) {
506 return;
507 }
508 if (closest.node == node) {
509 callback(closest);
510 } else if (closest.children) {
511 for (const child of closest.children) {
512 if (node.contains(child.node)) {
513 callback(child);
514 }
515 }
516 }
517}
518
519/**
520 * @param {Node} node

Callers 1

discoverContainedFunction · 0.85

Calls 3

closestMethod · 0.80
callbackFunction · 0.50
containsMethod · 0.45

Tested by

no test coverage detected