Sha256: 518b51a2e30c22ef2f65f216e3656fa8aa46f873e656af1c4093c7b0b20b3575
Contents?: true
Size: 1.12 KB
Versions: 198
Compression:
Stored size: 1.12 KB
Contents
export function getMetaValue(name) { const element = findElement(document.head, `meta[name="${name}"]`) if (element) { return element.getAttribute("content") } } export function findElements(root, selector) { if (typeof root == "string") { selector = root root = document } const elements = root.querySelectorAll(selector) return toArray(elements) } export function findElement(root, selector) { if (typeof root == "string") { selector = root root = document } return root.querySelector(selector) } export function dispatchEvent(element, type, eventInit = {}) { const { disabled } = element const { bubbles, cancelable, detail } = eventInit const event = document.createEvent("Event") event.initEvent(type, bubbles || true, cancelable || true) event.detail = detail || {} try { element.disabled = false element.dispatchEvent(event) } finally { element.disabled = disabled } return event } export function toArray(value) { if (Array.isArray(value)) { return value } else if (Array.from) { return Array.from(value) } else { return [].slice.call(value) } }
Version data entries
198 entries across 193 versions & 21 rubygems