Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dom.js « shared « frontend « content - gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d041ac09ae225f07e91d17b7a015fe297efd5520 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* global $ */

/**
 * Returns outerHeight of element **even if it's hidden**
 *
 * NOTE: Uses jQuery because there is no trivial way to do this in
 * vaniall JS, and it's nice that jQuery has a reliable out-of-the-box
 * solution.
 *
 * @param {Element} el
 */
export const getOuterHeight = el => $(el).outerHeight();

/**
 * Find the first child of the given element with the given tag name
 *
 * @param {Element} el
 * @param {String} tagName
 * @returns {Element | null} Returns first child that matches the given tagName (or null if not found)
 */
export const findChildByTagName = (el, tagName) =>
  Array.from(el.childNodes).find(x => x.tagName === tagName.toUpperCase());