lib/jsdom/living/helpers/shadow-dom.js
function findFlattenedSlotables(slot) {
  const result = [];

  const root = getRoot(slot);
  if (!isShadowRoot(root)) {
    return result;
  }

  const slotables = findSlotable(slot);

  if (slotables.length === 0) {
    for (const child of domSymbolTree.childrenIterator(slot)) {
      if (isSlotable(child)) {
        slotables.push(child);
      }
    }
  }

  for (const node of slotables) {
    if (isSlot(node) && isShadowRoot(getRoot(node))) {
      const temporaryResult = findFlattenedSlotables(node);
      result.push(...temporaryResult);
    } else {
      result.push(node);
    }
  }

  return result;
}
function findFlattenedSlotables(slot) {
  const result = [];

  const root = getRoot(slot);
  if (!isShadowRoot(root)) {
    return result;
  }

  const slotables = findSlotable(slot);

  if (slotables.length === 0) {
    for (const child of domSymbolTree.childrenIterator(slot)) {
      if (isSlotable(child)) {
        slotables.push(child);
      }
    }
  }

  for (const node of slotables) {
    if (isSlot(node) && isShadowRoot(getRoot(node))) {
      const temporaryResult = findFlattenedSlotables(node);
      result.push(...temporaryResult);
    } else {
      result.push(node);
    }
  }

  return result;
}
function findFlattenedSlotables ( slot ) { const result = [ ] ; const root = getRoot ( slot ) ; if ( ! isShadowRoot ( root ) ) { return result ; } const slotables = findSlotable ( slot ) ; if ( slotables . length === 0 ) { for ( const child of domSymbolTree . childrenIterator ( slot ) ) { if ( isSlotable ( child ) ) { slotables . push ( child ) ; } } } for ( const node of slotables ) { if ( isSlot ( node ) && isShadowRoot ( getRoot ( node ) ) ) { const temporaryResult = findFlattenedSlotables ( node ) ; result . push ( ... temporaryResult ) ; } else { result . push ( node ) ; } } return result ; }
https://dom.spec.whatwg.org/#find-flattened-slotables
https : // dom . spec . whatwg . org / #find - flattened - slotables