UNPKG

ant-design-x-vue

Version:

Craft AI-driven interfaces effortlessly

71 lines (70 loc) 1.93 kB
import S from "./canUseDom.mjs"; import g from "./contains.mjs"; const s = "data-vc-order", y = "vc-util-key", d = /* @__PURE__ */ new Map(); function l({ mark: e } = {}) { return e ? e.startsWith("data-") ? e : `data-${e}` : y; } function f(e) { return e.attachTo ? e.attachTo : document.querySelector("head") || document.body; } function p(e) { return e === "queue" ? "prependQueue" : e ? "prepend" : "append"; } function h(e) { return Array.from((d.get(e) || e).children).filter( (r) => r.tagName === "STYLE" ); } function C(e, r = {}) { if (!S()) return null; const { csp: n, prepend: c } = r, t = document.createElement("style"); t.setAttribute(s, p(c)), n != null && n.nonce && (t.nonce = n == null ? void 0 : n.nonce), t.innerHTML = e; const i = f(r), { firstChild: u } = i; if (c) { if (c === "queue") { const o = h(i).filter( (a) => ["prepend", "prependQueue"].includes(a.getAttribute(s)) ); if (o.length) return i.insertBefore(t, o[o.length - 1].nextSibling), t; } i.insertBefore(t, u); } else i.appendChild(t); return t; } function m(e, r = {}) { const n = f(r); return h(n).find((c) => c.getAttribute(l(r)) === e); } function x(e, r = {}) { const n = m(e, r); n && f(r).removeChild(n); } function N(e, r) { const n = d.get(e); if (!n || !g(document, n)) { const c = C("", r), { parentNode: t } = c; d.set(e, t), e.removeChild(c); } } function E() { d.clear(); } function M(e, r, n = {}) { var u, o, a; const c = f(n); N(c, n); const t = m(r, n); if (t) return (u = n.csp) != null && u.nonce && t.nonce !== ((o = n.csp) == null ? void 0 : o.nonce) && (t.nonce = (a = n.csp) == null ? void 0 : a.nonce), t.innerHTML !== e && (t.innerHTML = e), t; const i = C(e, n); return i.setAttribute(l(n), r), i; } export { E as clearContainerCache, C as injectCSS, x as removeCSS, M as updateCSS };