0.5.1 • Published 3 years ago

@gladio/dom-helpers v0.5.1

Weekly downloads
24
License
MIT
Repository
github
Last release
3 years ago

Dom helpers

Install

npm install --save @gladio/dom-helpers

Utilities

isDom

check if dom is available (generally used in univeral apps)

import { isDom } from "@gladio/dom-helpers"

function App() {
  if (isDom) {
    // rendering in a browser
  }
}

activeElement

Return the current active element in the dom

import { activeElement } from "@gladio/dom-helpers"

const App () {
  const currentActiveElement = activeElement()
}

contains

Checks whether or not a dom node is contains another given dom node. An usecase would be for checking a active element inside a container

import { contains } from "@gladio/dom-helpers"

function App() {
  // after mount
  if (contains(container, child)) {
    // do something with it
  }
}