@alegendstale/holly-components
Version:
Reusable UI components created using lit
42 lines (41 loc) • 1.16 kB
JavaScript
import u from "./adopt-css.js";
import g from "./is-registered-property.js";
const s = {
"<angle>": "0deg",
"<color>": "transparent",
"<custom-ident>": "none",
"<image>": "linear-gradient(transparent 0% 100%)",
"<integer>": "0",
"<length>": "0px",
"<length-percentage>": "0px",
"<number>": "0",
"<percentage>": "0%",
"<resolution>": "1dppx",
"<string>": "''",
"<time>": "0s",
"<transform-function>": "scale(1)",
"<transform-list>": "scale(1)",
"<url>": "url('')"
};
let a = /* @__PURE__ */ new Map();
function f(t, n = {}, r = globalThis.document) {
let i = a.get(r);
if (!t.startsWith("--") || i && t in i || g(t, r))
return;
let e = {
syntax: n.syntax || "*",
inherits: n.inherits ?? !0
};
n.initialValue !== void 0 ? e.initialValue = n.initialValue : e.syntax !== "*" && e.syntax in s && (e.initialValue = s[e.syntax]);
let l = u(`@layer style-observer-registered-properties {
@property ${t} {
syntax: "${e.syntax}";
inherits: ${e.inherits};
${e.initialValue !== void 0 ? `initial-value: ${e.initialValue};` : ""}
}
}`, r);
i || (i = {}, a.set(r, i)), i[t] = l;
}
export {
f as default
};