summaryrefslogtreecommitdiff
path: root/chromium/chrome/browser/resources/ntp4/util.js
blob: 637aacec4bc5efbd2c4cd199205669f6360121da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import {findAncestor} from 'chrome://resources/js/util.js';

/**
 * @param {Node} el A node to search for ancestors with |className|.
 * @param {string} className A class to search for.
 * @return {Element} A node with class of |className| or null if none is found.
 */
export function findAncestorByClass(el, className) {
  return /** @type {Element} */ (findAncestor(el, function(el) {
    return el.classList && el.classList.contains(className);
  }));
}