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.

fix: accept <source> as <video> child (#5264)

Bogdan Chadkinb64a0c077ad6
diff --git a/apps/builder/app/shared/content-model.test.tsx b/apps/builder/app/shared/content-model.test.tsx
index 58fa198a02..3bbc20b513 100644
--- a/apps/builder/app/shared/content-model.test.tsx
+++ b/apps/builder/app/shared/content-model.test.tsx
@@ -489,6 +489,22 @@ test("edge case: support a > img", () => {
).toBeTruthy();
});
+test("support video > source", () => {
+ expect(
+ isTreeSatisfyingContentModel({
+ ...renderData(
+ <ws.element ws:tag="body" ws:id="bodyId">
+ <ws.element ws:tag="video">
+ <ws.element ws:tag="source" />
+ </ws.element>
+ </ws.element>
+ ),
+ metas: defaultMetas,
+ instanceSelector: ["bodyId"],
+ })
+ ).toBeTruthy();
+});
+
describe("component content model", () => {
test("restrict children with specific component", () => {
expect(
diff --git a/apps/builder/app/shared/content-model.ts b/apps/builder/app/shared/content-model.ts
index 9775182870..aa7260cb93 100644
--- a/apps/builder/app/shared/content-model.ts
+++ b/apps/builder/app/shared/content-model.ts
@@ -114,7 +114,10 @@ const getElementChildren = (
let elementChildren: string[] =
tag === undefined ? ["transparent"] : elementsByTag[tag].children;
if (elementChildren.includes("transparent") && allowedCategories) {
- elementChildren = allowedCategories;
+ // merge categories from parent and current element when transparent occured
+ elementChildren = elementChildren.flatMap((category) =>
+ category === "transparent" ? allowedCategories : category
+ );
}
// introduce custom non-interactive category to restrict nesting interactive elements
// like button > button or a > input