function findAndHighlightMatches_(request, root) {
    let foundMatches = false;
    function doSearch(node) {
      if (node.nodeName == 'TEMPLATE' && node.hasAttribute('route-path') &&
          !node.if && !node.hasAttribute(SKIP_SEARCH_CSS_ATTRIBUTE)) {
        request.queue_.addRenderTask(new RenderTask(request, node));
        return;
      }

      if (IGNORED_ELEMENTS.has(node.nodeName))
        return;

      if (node instanceof HTMLElement) {
        const element = /** @type {HTMLElement} */ (node);
        if (element.hasAttribute(SKIP_SEARCH_CSS_ATTRIBUTE) ||
            element.hasAttribute('hidden') || element.style.display == 'none') {
          return;
        }
      }

      if (node.nodeType == Node.TEXT_NODE) {
        const textContent = node.nodeValue.trim();
        if (textContent.length == 0)
          return;

        if (request.regExp.test(textContent)) {
          foundMatches = true;
          revealParentSection_(node, request.rawQuery_);

          // Don't highlight <select> nodes, yellow rectangles can't be
          // displayed within an <option>.
          // TODO(dpapad): highlight <select> controls with a search bubble
          // instead.
          if (node.parentNode.nodeName != 'OPTION') {
            request.addTextObserver(node);
            cr.search_highlight_utils.highlight(
                node, textContent.split(request.regExp));
          }
        }
        // Returning early since TEXT_NODE nodes never have children.
        return;
      }

      let child = node.firstChild;
      while (child !== null) {
        // Getting a reference to the |nextSibling| before calling doSearch()
        // because |child| could be removed from the DOM within doSearch().
        const nextSibling = child.nextSibling;
        doSearch(child);
        child = nextSibling;
      }

      const shadowRoot = node.shadowRoot;
      if (shadowRoot)
        doSearch(shadowRoot);
    }

    doSearch(root);
    return foundMatches;
  }
/**
   * Traverses the entire DOM (including Shadow DOM), finds text nodes that
   * match the given regular expression and applies the highlight UI. It also
   * ensures that <settings-section> instances become visible if any matches
   * occurred under their subtree.
   *
   * @param {!settings.SearchRequest} request
   * @param {!Node} root The root of the sub-tree to be searched
   * @private
   */
Traverses the entire DOM (including Shadow DOM), finds text nodes that
match the given regular expression and applies the highlight UI. It also
ensures that  instances become visible if any matches
occurred under their subtree.

@param {!settings.SearchRequest} request
@param {!Node} root The root of the sub-tree to be searched
@private
Traverses the entire DOM ( including Shadow DOM ) finds text nodes that match the given regular expression and applies the highlight UI . It also ensures that instances become visible if any matches occurred under their subtree . @param { !settings . SearchRequest } request @param { !Node } root The root of the sub - tree to be searched @private
function findAndHighlightMatches_(request, root) {
    let foundMatches = false;
    function doSearch(node) {
      if (node.nodeName == 'TEMPLATE' && node.hasAttribute('route-path') &&
          !node.if && !node.hasAttribute(SKIP_SEARCH_CSS_ATTRIBUTE)) {
        request.queue_.addRenderTask(new RenderTask(request, node));
        return;
      }
      if (IGNORED_ELEMENTS.has(node.nodeName))
        return;
      if (node instanceof HTMLElement) {
        const element =  (node);
        if (element.hasAttribute(SKIP_SEARCH_CSS_ATTRIBUTE) ||
            element.hasAttribute('hidden') || element.style.display == 'none') {
          return;
        }
      }
      if (node.nodeType == Node.TEXT_NODE) {
        const textContent = node.nodeValue.trim();
        if (textContent.length == 0)
          return;
        if (request.regExp.test(textContent)) {
          foundMatches = true;
          revealParentSection_(node, request.rawQuery_);
          if (node.parentNode.nodeName != 'OPTION') {
            request.addTextObserver(node);
            cr.search_highlight_utils.highlight(
                node, textContent.split(request.regExp));
          }
        }
        return;
      }
      let child = node.firstChild;
      while (child !== null) {
        const nextSibling = child.nextSibling;
        doSearch(child);
        child = nextSibling;
      }
      const shadowRoot = node.shadowRoot;
      if (shadowRoot)
        doSearch(shadowRoot);
    }
    doSearch(root);
    return foundMatches;
  }
function findAndHighlightMatches_ ( request , root ) { let foundMatches = false ; function doSearch ( node ) { if ( node . nodeName == 'TEMPLATE' && node . hasAttribute ( 'route-path' ) && ! node . if && ! node . hasAttribute ( SKIP_SEARCH_CSS_ATTRIBUTE ) ) { request . queue_ . addRenderTask ( new RenderTask ( request , node ) ) ; return ; } if ( IGNORED_ELEMENTS . has ( node . nodeName ) ) return ; if ( node instanceof HTMLElement ) { const element = ( node ) ; if ( element . hasAttribute ( SKIP_SEARCH_CSS_ATTRIBUTE ) || element . hasAttribute ( 'hidden' ) || element . style . display == 'none' ) { return ; } } if ( node . nodeType == Node . TEXT_NODE ) { const textContent = node . nodeValue . trim ( ) ; if ( textContent . length == 0 ) return ; if ( request . regExp . test ( textContent ) ) { foundMatches = true ; revealParentSection_ ( node , request . rawQuery_ ) ; if ( node . parentNode . nodeName != 'OPTION' ) { request . addTextObserver ( node ) ; cr . search_highlight_utils . highlight ( node , textContent . split ( request . regExp ) ) ; } } return ; } let child = node . firstChild ; while ( child !== null ) { const nextSibling = child . nextSibling ; doSearch ( child ) ; child = nextSibling ; } const shadowRoot = node . shadowRoot ; if ( shadowRoot ) doSearch ( shadowRoot ) ; } doSearch ( root ) ; return foundMatches ; }
Traverses the entire DOM (including Shadow DOM), finds text nodes that
 match the given regular expression and applies the highlight UI.
Traverses the entire DOM ( including Shadow DOM ) finds text nodes that match the given regular expression and applies the highlight UI .
/** @type {HTMLElement} */ // Don't highlight <select> nodes, yellow rectangles can't be // displayed within an <option>. // TODO(dpapad): highlight <select> controls with a search bubble // instead. // Returning early since TEXT_NODE nodes never have children. // Getting a reference to the |nextSibling| before calling doSearch() // because |child| could be removed from the DOM within doSearch().