Skip to content

Commit 6d7c527

Browse files
committed
fix: accept <source> as <video> child (#5264)
Transparent category was overriden by parent categories without merging others from current element.
1 parent 9ff8cbe commit 6d7c527

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

apps/builder/app/shared/content-model.test.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,22 @@ test("edge case: support a > img", () => {
489489
).toBeTruthy();
490490
});
491491

492+
test("support video > source", () => {
493+
expect(
494+
isTreeSatisfyingContentModel({
495+
...renderData(
496+
<ws.element ws:tag="body" ws:id="bodyId">
497+
<ws.element ws:tag="video">
498+
<ws.element ws:tag="source" />
499+
</ws.element>
500+
</ws.element>
501+
),
502+
metas: defaultMetas,
503+
instanceSelector: ["bodyId"],
504+
})
505+
).toBeTruthy();
506+
});
507+
492508
describe("component content model", () => {
493509
test("restrict children with specific component", () => {
494510
expect(

apps/builder/app/shared/content-model.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ const getElementChildren = (
114114
let elementChildren: string[] =
115115
tag === undefined ? ["transparent"] : elementsByTag[tag].children;
116116
if (elementChildren.includes("transparent") && allowedCategories) {
117-
elementChildren = allowedCategories;
117+
// merge categories from parent and current element when transparent occured
118+
elementChildren = elementChildren.flatMap((category) =>
119+
category === "transparent" ? allowedCategories : category
120+
);
118121
}
119122
// introduce custom non-interactive category to restrict nesting interactive elements
120123
// like button > button or a > input

0 commit comments

Comments
 (0)