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.14.0 app/assets/js/helpers/dom.js
coveragebook_components-0.13.1 app/assets/js/helpers/dom.js
coveragebook_components-0.13.0 app/assets/js/helpers/dom.js
coveragebook_components-0.12.2 app/assets/js/helpers/dom.js
coveragebook_components-0.12.1 app/assets/js/helpers/dom.js
coveragebook_components-0.12.0 app/assets/js/helpers/dom.js
coveragebook_components-0.11.0 app/assets/js/helpers/dom.js
coveragebook_components-0.10.1.beta.2 app/assets/js/helpers/dom.js
coveragebook_components-0.10.1.beta.1 app/assets/js/helpers/dom.js
coveragebook_components-0.10.1.beta.0 app/assets/js/helpers/dom.js
coveragebook_components-0.10.0 app/assets/js/helpers/dom.js
coveragebook_components-0.9.1 app/assets/js/helpers/dom.js
coveragebook_components-0.9.0 app/assets/js/helpers/dom.js
coveragebook_components-0.8.9 app/assets/js/helpers/dom.js
coveragebook_components-0.8.8 app/assets/js/helpers/dom.js
coveragebook_components-0.8.7 app/assets/js/helpers/dom.js
coveragebook_components-0.8.6 app/assets/js/helpers/dom.js
coveragebook_components-0.8.5 app/assets/js/helpers/dom.js
coveragebook_components-0.8.4 app/assets/js/helpers/dom.js
coveragebook_components-0.8.3 app/assets/js/helpers/dom.js