@zero-dependency/dom
v1.8.4
Published
DOM utils
Downloads
19
Readme
@zero-dependency/dom
Installation
npm install @zero-dependency/dom
yarn add @zero-dependency/dom
pnpm add @zero-dependency/dom
Usage
import { el, observeElement, waitElement } from '@zero-dependency/dom'
// createElement
const element = el('div', { class: 'foo' }, 'Hello World')
document.body.appendChild(element)
// observeElement
observeElement(element, (mutation, observer) => {
console.log(mutation.target.textContent) // 'hello world'
observer.disconnect()
})
element.textContent = element.textContent.toLowerCase() // 'hello world'
// waitElement
const el = await waitElement('div.card')
console.log(el) // <div class="card">...</div>