Skip to content

Commit f75fda9

Browse files
committed
Fix parsing flex-basis in shorthand flex when not a value
1 parent 79811e2 commit f75fda9

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/properties/flex.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ module.exports.parse = function parse(v, opt = {}) {
9292
} else {
9393
return;
9494
}
95-
if (val3.type === "Calc" && !val3.isNumber) {
95+
if (val3.type === "GlobalKeyword" || val3.type === "Identifier") {
96+
flex["flex-basis"] = val3.name;
97+
} else if (val3.type === "Calc" && !val3.isNumber) {
9698
flex["flex-basis"] = `${val3.name}(${val3.value})`;
9799
} else if (val3.type === "Dimension") {
98100
flex["flex-basis"] = `${val3.value}${val3.unit}`;

test/CSSStyleDeclaration.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,12 @@ describe("CSSStyleDeclaration", () => {
11431143
assert.strictEqual(style.getPropertyValue("flex-shrink"), "1");
11441144
assert.strictEqual(style.getPropertyValue("flex-basis"), "250px");
11451145
style.removeProperty("flex");
1146+
style.setProperty("flex", "0 0 auto");
1147+
assert.strictEqual(style.getPropertyValue("flex"), "0 0 auto");
1148+
assert.strictEqual(style.getPropertyValue("flex-grow"), "0");
1149+
assert.strictEqual(style.getPropertyValue("flex-shrink"), "0");
1150+
assert.strictEqual(style.getPropertyValue("flex-basis"), "auto");
1151+
style.removeProperty("flex");
11461152
style.setProperty("flex", "2");
11471153
assert.strictEqual(style.getPropertyValue("flex-grow"), "2");
11481154
assert.strictEqual(style.getPropertyValue("flex-shrink"), "1");

0 commit comments

Comments
 (0)