Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
fix: Suppoort min() and other functions in advanced section (#3215)
Oleg Isonen8ac51b5d396e
diff --git a/packages/css-data/src/parse-css-value.test.ts b/packages/css-data/src/parse-css-value.test.tsindex deb933e0ed..f3a3ec0bae 100644--- a/packages/css-data/src/parse-css-value.test.ts+++ b/packages/css-data/src/parse-css-value.test.ts@@ -107,22 +107,19 @@ describe("Parse CSS value", () => {describe("Tuples", () => {test("backgroundPosition", () => {- expect(parseCssValue("backgroundPosition", "left top"))- .toMatchInlineSnapshot(`-{- "type": "tuple",- "value": [- {- "type": "keyword",- "value": "left",- },- {- "type": "keyword",- "value": "top",- },- ],-}-`);+ expect(parseCssValue("backgroundPosition", "left top")).toEqual({+ type: "tuple",+ value: [+ {+ type: "keyword",+ value: "left",+ },+ {+ type: "keyword",+ value: "top",+ },+ ],+ });});});diff --git a/packages/css-data/src/parse-css-value.ts b/packages/css-data/src/parse-css-value.tsindex 654e0ce489..9baa69192e 100644--- a/packages/css-data/src/parse-css-value.ts+++ b/packages/css-data/src/parse-css-value.ts@@ -20,26 +20,21 @@ export const cssTryParseValue = (input: string) => {}};+// Because csstree parser has bugs we use CSSStyleValue to validate css properties if available+// and fall back to csstree.export const isValidDeclaration = (property: string,value: string): boolean => {- const ast = cssTryParseValue(value);-- if (ast == null) {- return false;- }-const cssPropertyName = hyphenate(property);- const matchResult = csstree.lexer.matchProperty(cssPropertyName, ast);-- const isValidDeclaration = matchResult.matched != null;-- // @todo remove after fix https://github.com/csstree/csstree/issues/246- if (isValidDeclaration && typeof CSSStyleValue !== "undefined") {+ // @todo remove after csstree fixes+ // - https://github.com/csstree/csstree/issues/246+ // - https://github.com/csstree/csstree/issues/164+ if (typeof CSSStyleValue !== "undefined") {try {CSSStyleValue.parse(cssPropertyName, value);+ return true;} catch {warnOnce(true,@@ -50,7 +45,15 @@ export const isValidDeclaration = (}}- return isValidDeclaration;+ const ast = cssTryParseValue(value);++ if (ast == null) {+ return false;+ }++ const matchResult = csstree.lexer.matchProperty(cssPropertyName, ast);++ return matchResult.matched != null;};export const parseCssValue = (@@ -66,7 +69,7 @@ export const parseCssValue = (return invalidValue;}- if (!isValidDeclaration(property, input)) {+ if (isValidDeclaration(property, input) === false) {return invalidValue;}