MCPcopy Create free account
hub / github.com/Nynxz/ComfyUI-IdeogramHelper / patchStyle

Function patchStyle

web/main.js:7025–7084  ·  view source on GitHub ↗
(el, prev, next)

Source from the content-addressed store, hash-verified

7023const CSS_VAR_TEXT = /* @__PURE__ */ Symbol("");
7024const displayRE = /(?:^|;)\s*display\s*:/;
7025function patchStyle(el, prev, next) {
7026 const style = el.style;
7027 const isCssString = isString(next);
7028 let hasControlledDisplay = false;
7029 if (next && !isCssString) {
7030 if (prev) {
7031 if (!isString(prev)) {
7032 for (const key in prev) {
7033 if (next[key] == null) {
7034 setStyle(style, key, "");
7035 }
7036 }
7037 } else {
7038 for (const prevStyle of prev.split(";")) {
7039 const key = prevStyle.slice(0, prevStyle.indexOf(":")).trim();
7040 if (next[key] == null) {
7041 setStyle(style, key, "");
7042 }
7043 }
7044 }
7045 }
7046 for (const key in next) {
7047 if (key === "display") {
7048 hasControlledDisplay = true;
7049 }
7050 const value = next[key];
7051 if (value != null) {
7052 if (!shouldPreserveTextareaResizeStyle(
7053 el,
7054 key,
7055 !isString(prev) && prev ? prev[key] : void 0,
7056 value
7057 )) {
7058 setStyle(style, key, value);
7059 }
7060 } else {
7061 setStyle(style, key, "");
7062 }
7063 }
7064 } else {
7065 if (isCssString) {
7066 if (prev !== next) {
7067 const cssVarText = style[CSS_VAR_TEXT];
7068 if (cssVarText) {
7069 next += ";" + cssVarText;
7070 }
7071 style.cssText = next;
7072 hasControlledDisplay = displayRE.test(next);
7073 }
7074 } else if (prev) {
7075 el.removeAttribute("style");
7076 }
7077 }
7078 if (vShowOriginalDisplay in el) {
7079 el[vShowOriginalDisplay] = hasControlledDisplay ? style.display : "";
7080 if (el[vShowHidden]) {
7081 style.display = "none";
7082 }

Callers 1

patchPropFunction · 0.85

Calls 3

isStringFunction · 0.85
setStyleFunction · 0.85

Tested by

no test coverage detected