Sha256: 5eb89521342c6d53815de6da334c759b5d8ee48655519befc4db853cbd0f6f83

Contents?: true

Size: 821 Bytes

Versions: 51

Compression:

Stored size: 821 Bytes

Contents

import { isNumeric } from "@helpers/lang";

function getHiddenElementDimensions(el, display = "block") {
  let size;
  if (el.style.display === "none") {
    el.style.display = display;
    size = el.getBoundingClientRect();
    el.style.display = "none";
  } else {
    size = el.getBoundingClientRect();
  }

  return size;
}

function castAttributeValue(value) {
  if (value === "false") {
    return false;
  }

  if (value === "true") {
    return true;
  }

  if (isNumeric(value)) {
    return parseInt(value, 10);
  }

  return value;
}

function isNode(o) {
  return typeof Node === "object"
    ? o instanceof Node
    : o &&
        typeof o === "object" &&
        typeof o.nodeType === "number" &&
        typeof o.nodeName === "string";
}

export { getHiddenElementDimensions, castAttributeValue, isNode };

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
coveragebook_components-0.6.2 app/assets/js/helpers/dom.js
coveragebook_components-0.6.1 app/assets/js/helpers/dom.js
coveragebook_components-0.6.0 app/assets/js/helpers/dom.js
coveragebook_components-0.5.7 app/assets/js/helpers/dom.js
coveragebook_components-0.5.6 app/assets/js/helpers/dom.js
coveragebook_components-0.5.5 app/assets/js/helpers/dom.js
coveragebook_components-0.5.4 app/assets/js/helpers/dom.js
coveragebook_components-0.5.3 app/assets/js/helpers/dom.js
coveragebook_components-0.5.2 app/assets/js/helpers/dom.js
coveragebook_components-0.5.1 app/assets/js/helpers/dom.js
coveragebook_components-0.5.0 app/assets/js/helpers/dom.js