Skip to content
This repository was archived by the owner on Mar 22, 2019. It is now read-only.

Commit 9021283

Browse files
authoredFeb 13, 2018
Merge pull request #90 from hail2u/issue89
Preserve `min-width:0%` as it is
2 parents abe0388 + f9654a3 commit 9021283

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed
 

‎index.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,25 @@ function toShortestColor(m, leading, r1, r2, g1, g2, b1, b2) {
101101
}
102102

103103
// Remove unit from 0 length and 0 percentage if possible
104-
function removeUnitOfZero(prop, m, leading, num, u, position, value) {
104+
function removeUnitOfZero(
105+
preserveHacks,
106+
prop,
107+
m,
108+
leading,
109+
num,
110+
u,
111+
position,
112+
value
113+
) {
105114
if (
106115
prop === "flex" ||
107116
prop === "-ms-flex" ||
108117
prop === "-webkit-flex" ||
109118
prop === "flex-basis" ||
110119
prop === "-webkit-flex-basis" ||
111120
value.indexOf("calc(") !== -1 ||
112-
prop.startsWith("--")
121+
prop.startsWith("--") ||
122+
(preserveHacks && prop === "min-width" && u === "%")
113123
) {
114124
return m;
115125
}
@@ -160,7 +170,7 @@ function removeCalcWhiteSpaces(m, leading, calc) {
160170
}
161171

162172
// Wring value of declaration
163-
function wringValue(prop, value) {
173+
function wringValue(preserveHacks, prop, value) {
164174
return value
165175
.replace(re.colorFunction, toRGBColor)
166176
.replace(re.colorHex, toShortestColor)
@@ -170,7 +180,7 @@ function wringValue(prop, value) {
170180
.replace(re.whiteSpacesAfterSymbol, "$1")
171181
.replace(re.whiteSpacesBeforeSymbol, "$1")
172182
.replace(re.numberLeadingZeros, "$1$2")
173-
.replace(re.zeroValueUnit, removeUnitOfZero.bind(null, prop))
183+
.replace(re.zeroValueUnit, removeUnitOfZero.bind(null, preserveHacks, prop))
174184
.replace(re.decimalWithZeros, "$1$2$3.$4")
175185
.replace(re.timeEndsWithZero, toShortestTime)
176186
.replace(re.angle, toShortestAngle)
@@ -393,7 +403,7 @@ function wringDecl(preserveHacks, decl) {
393403

394404
let values = list.comma(value);
395405

396-
value = values.map(wringValue.bind(null, prop)).join(",");
406+
value = values.map(wringValue.bind(null, preserveHacks, prop)).join(",");
397407

398408
if (re.propertyMultipleValues.test(prop)) {
399409
values = list.space(value);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.foo{min-width:0%}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.foo {
2+
min-width: 0%;
3+
}

0 commit comments

Comments
 (0)
This repository has been archived.