Skip to content

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.

experimental: parse unknown properties as unparsed value (#3658)

Bogdan Chadkin18005cf5d962
diff --git a/apps/builder/app/shared/copy-paste/plugin-webflow/__generated__/style-presets.ts b/apps/builder/app/shared/copy-paste/plugin-webflow/__generated__/style-presets.ts
index b6cdaba570..3f2aca1455 100644
--- a/apps/builder/app/shared/copy-paste/plugin-webflow/__generated__/style-presets.ts
+++ b/apps/builder/app/shared/copy-paste/plugin-webflow/__generated__/style-presets.ts
@@ -12010,21 +12010,21 @@ export const styles = {
{
property: "animationTimeline",
value: {
- type: "invalid",
- value: "",
+ type: "unparsed",
+ value: "auto",
},
},
{
property: "animationRangeStart",
value: {
- type: "invalid",
+ type: "unparsed",
value: "normal",
},
},
{
property: "animationRangeEnd",
value: {
- type: "invalid",
+ type: "unparsed",
value: "normal",
},
},
diff --git a/packages/css-data/src/parse-css-value.test.ts b/packages/css-data/src/parse-css-value.test.ts
index e5ef759a58..cb8db0b976 100644
--- a/packages/css-data/src/parse-css-value.test.ts
+++ b/packages/css-data/src/parse-css-value.test.ts
@@ -1,5 +1,6 @@
import { describe, test, expect } from "@jest/globals";
import { parseCssValue } from "./parse-css-value";
+import type { StyleProperty } from "@webstudio-is/css-engine";
describe("Parse CSS value", () => {
describe("number value", () => {
@@ -295,3 +296,22 @@ test("parse transition-behavior property as layers", () => {
value: "normal, invalid",
});
});
+
+test("parse unknown properties as unparsed", () => {
+ expect(parseCssValue("animationTimeline" as StyleProperty, "auto")).toEqual({
+ type: "unparsed",
+ value: "auto",
+ });
+ expect(
+ parseCssValue("animationRangeStart" as StyleProperty, "normal")
+ ).toEqual({
+ type: "unparsed",
+ value: "normal",
+ });
+ expect(parseCssValue("animationRangeEnd" as StyleProperty, "normal")).toEqual(
+ {
+ type: "unparsed",
+ value: "normal",
+ }
+ );
+});
diff --git a/packages/css-data/src/parse-css-value.ts b/packages/css-data/src/parse-css-value.ts
index 49e8439f32..6d2b2666ce 100644
--- a/packages/css-data/src/parse-css-value.ts
+++ b/packages/css-data/src/parse-css-value.ts
@@ -92,6 +92,11 @@ export const isValidDeclaration = (
const matchResult = csstree.lexer.matchProperty(cssPropertyName, ast);
+ // allow to parse unknown properties as unparsed
+ if (matchResult.error?.message.includes("Unknown property")) {
+ return true;
+ }
+
return matchResult.matched != null;
};
@@ -239,8 +244,8 @@ export const parseCssValue = (
const values = keywordValues[property as keyof typeof keywordValues];
if (values === undefined) {
return {
- type: "invalid",
- value: "",
+ type: "unparsed",
+ value: input,
};
}
const lettersRegex = /[^a-zA-Z]+/g;