UNPKG

@zag-js/mutation-observer

Version:
30 lines (29 loc) 876 B
// src/observe-attributes.ts function observeAttributes(node, attributes, fn) { if (!node) return; const win = node.ownerDocument.defaultView || window; const obs = new win.MutationObserver((changes) => { for (const change of changes) { if (change.type === "attributes" && change.attributeName && attributes.includes(change.attributeName)) { fn(change); } } }); obs.observe(node, { attributes: true, attributeFilter: attributes }); return () => obs.disconnect(); } // src/observe-children.ts function observeChildren(node, fn) { if (!node) return; const win = node.ownerDocument.defaultView || window; const obs = new win.MutationObserver(fn); obs.observe(node, { childList: true, subtree: true }); return () => obs.disconnect(); } export { observeAttributes, observeChildren }; //# sourceMappingURL=index.mjs.map