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

Function querySelectorInSlot

src/core/dom/query.js:403–416  ·  view source on GitHub ↗
(slot, selector)

Source from the content-addressed store, hash-verified

401 * @return {HTMLElement|null}
402 */
403export function querySelectorInSlot(slot, selector) {
404 const nodes = /** @type {HTMLElement[]} */ (slot.assignedElements());
405 for (let i = 0; i < nodes.length; i++) {
406 const node = nodes[i];
407 if (matches(node, selector)) {
408 return node;
409 }
410 const child = scopedQuerySelector(node, selector);
411 if (child) {
412 return child;
413 }
414 }
415 return null;
416}
417
418/**
419 * Finds a matching node inside an HTML template slot's children

Callers 2

useDatePickerInputFunction · 0.90
AppBannerFunction · 0.90

Calls 2

scopedQuerySelectorFunction · 0.85
matchesFunction · 0.70

Tested by

no test coverage detected