@homebound/truss 2.1.0 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -884,17 +884,30 @@ ${body}
884
884
  }
885
885
  function buildStyleHashProperties(segments, mapping, maybeIncHelperName) {
886
886
  const propGroups = /* @__PURE__ */ new Map();
887
+ function pushEntry(cssProp, entry) {
888
+ if (!propGroups.has(cssProp)) propGroups.set(cssProp, []);
889
+ const entries = propGroups.get(cssProp);
890
+ if (!entry.isConditional) {
891
+ for (let i = entries.length - 1; i >= 0; i--) {
892
+ if (!entries[i].isConditional) {
893
+ entries.splice(i, 1);
894
+ }
895
+ }
896
+ }
897
+ entries.push(entry);
898
+ }
887
899
  for (const seg of segments) {
888
900
  if (seg.error || seg.styleArrayArg || seg.typographyLookup) continue;
889
901
  const { prefix } = segmentContext(seg, mapping);
902
+ const isConditional = prefix !== "";
890
903
  if (seg.variableProps) {
891
904
  for (const prop of seg.variableProps) {
892
905
  const className = prefix ? `${prefix}${seg.abbr}_var` : `${seg.abbr}_var`;
893
906
  const varName = toCssVariableName(className, seg.abbr, prop);
894
- if (!propGroups.has(prop)) propGroups.set(prop, []);
895
- propGroups.get(prop).push({
907
+ pushEntry(prop, {
896
908
  className,
897
909
  isVariable: true,
910
+ isConditional,
898
911
  varName,
899
912
  argNode: seg.argNode,
900
913
  incremented: seg.incremented,
@@ -905,8 +918,7 @@ function buildStyleHashProperties(segments, mapping, maybeIncHelperName) {
905
918
  for (const [cssProp, value] of Object.entries(seg.variableExtraDefs)) {
906
919
  const extraBase = `${seg.abbr}_${cssProp}`;
907
920
  const extraName = prefix ? `${prefix}${extraBase}` : extraBase;
908
- if (!propGroups.has(cssProp)) propGroups.set(cssProp, []);
909
- propGroups.get(cssProp).push({ className: extraName, isVariable: false });
921
+ pushEntry(cssProp, { className: extraName, isVariable: false, isConditional });
910
922
  }
911
923
  }
912
924
  } else {
@@ -914,8 +926,7 @@ function buildStyleHashProperties(segments, mapping, maybeIncHelperName) {
914
926
  for (const [cssProp, val] of Object.entries(seg.defs)) {
915
927
  const baseName = computeStaticBaseName(seg, cssProp, String(val), isMultiProp, mapping);
916
928
  const className = prefix ? `${prefix}${baseName}` : baseName;
917
- if (!propGroups.has(cssProp)) propGroups.set(cssProp, []);
918
- propGroups.get(cssProp).push({ className, isVariable: false });
929
+ pushEntry(cssProp, { className, isVariable: false, isConditional });
919
930
  }
920
931
  }
921
932
  }