How to use is-dom - 8 common examples

To help you get started, we’ve selected a few is-dom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mattdesl / canvas-sketch / lib / util.js View on Github external
export function isCanvas (element) {
  return isDOM(element) && /canvas/i.test(element.nodeName) && typeof element.getContext === 'function';
}
github flauwekeul / honeycomb / src / views / dom / index.js View on Github external
export default function DOM({ container, hex, origin = Point(0, 0) }) {
    if (!isDom(container)) {
        console.warn(`Container is not a valid dom node: ${container}.`)
        return false
    }

    Hex.prototype.element(hex.element)

    return Object.assign(
        Object.create(prototype),
        {
            origin: Point(origin),
            container,
            hex
        }
    )
}
github ritz078 / embed-js / packages / embed-js / src / index.js View on Github external
function isElementPresent({ input, target }) {
  return isDom(input) || (target && isDom(target))
}
github ritz078 / embed-js / packages / embed-plugin-twitter / src / index.js View on Github external
function renderTweet({ input, _services }, { twttr, onLoad }) {
  if (!isDom(input)) {
    throw new Error("input should be a DOM element to embed tweet.")
  }
  if (_services.filter(service => service.id === "twitter").length) {
    twttr.widgets.load(input)
    twttr.events.bind("loaded", onLoad)
  }
}
github kuy / redux-tooltip / src / utils.js View on Github external
export function placement(place, content, origin) {
  const gap = 12;
  const dim = dimension(content);
  let pos = { top: origin.y, right: origin.x, bottom: origin.y, left: origin.x, width: 0, height: 0 }

  if (isDOM(origin)) {
    pos = position(origin)
  } else if (typeof origin === 'string') {
    pos = position(document.getElementById(origin))
  }

  let offset = { width: dim.width, height: dim.height };
  switch(place) {
  case 'top': case 'bottom':
    offset.left = `${pos.left + (pos.width * 0.5) - (dim.width * 0.5)}px`;
    break;
  case 'left': case 'right':
    offset.top = `${pos.top + (pos.height * 0.5) - (dim.height * 0.5)}px`;
    break;
  }

  switch(place) {
github ritz078 / embed-js / packages / embed-js / src / index.js View on Github external
fetch: isBrowser && (window.fetch || window.unfetch),

      inlineEmbed: true,
      replaceUrl: false,
      _embeds: [],
      _services: []
    }

    let { input, plugins = [], preset } = options
    if (!input) {
      throw new Error(
        "You need to pass input element or string in the options object."
      )
    }

    const inputString = isDom(input) ? input.innerHTML : input

    this.options = extend({}, defaultOptions, options, {
      result: inputString,
      plugins: preset ? plugins.concat(preset) : plugins,
      inputString
    })
  }
github anthonyshort / deku / lib / helpers / dom.js View on Github external
export function isElement (el) {
  return isDom(el)
}
github storybookjs / react-inspector / src / index.js View on Github external
const Inspector = ({ table = false, data, ...rest }) => {
  if (table) {
    return ;
  }

  if (isDOM(data)) return ;

  return ;
};

is-dom

Check if the given object is a dom node

MIT
Latest version published 5 years ago

Package Health Score

62 / 100
Full package analysis

Popular is-dom functions