Skip to content

The VS Code of video editing, built for agents.

TypeScript

Update JSX handling to reject `<audio>` and `<video>` tags in paint hosts

konstantin-paulusd4b23008f0ab
diff --git a/apps/cli/reference/jsx/html-paint.md b/apps/cli/reference/jsx/html-paint.md
index a6700f41..be065e84 100644
--- a/apps/cli/reference/jsx/html-paint.md
+++ b/apps/cli/reference/jsx/html-paint.md
@@ -45,3 +45,4 @@ Like all paints it stacks with siblings in document order and clips to the paren
- The content lives only as long as its mount: it is not persisted and does not render in exports yet.
- CSS animations in the markup play on the wall clock, not the composition playhead. Animate the parent element's props with [keyframes](./keyframes.md) for frame-accurate motion.
- Cross-origin subresources (e.g. remote images) are excluded from the painted output by the browser's read-back rules; use local assets.
+- `<audio>` and `<video>` tags are rejected: media doesn't play under a paint host. Use the [`<Audio>`](./audio.md) and [`<Video>`](./video.md) composition elements, which own playback and the timeline.
diff --git a/apps/web/src/utils/jsx.ts b/apps/web/src/utils/jsx.ts
index 921b5109..ad2571c3 100644
--- a/apps/web/src/utils/jsx.ts
+++ b/apps/web/src/utils/jsx.ts
@@ -613,6 +613,12 @@ export class WorldDocument implements ProjectDocument<HostNode> {
public createElement(tag: string): HostNode {
// When the tag starts with a lowercase letter, it's a DOM vocabulary
if (tag[0] === tag[0].toLowerCase()) {
+ // Media doesn't play under a paint host — playback and the timeline
+ // belong to the composition elements.
+ assert(
+ tag !== "audio" && tag !== "video",
+ `<${tag}> is not supported as html content; use the <${tag === "audio" ? "Audio" : "Video"}> composition element instead`,
+ );
return SVGElements.has(tag)
? document.createElementNS(SVG_NS, tag)
: document.createElement(tag);
diff --git a/packages/jsx/src/jsx-runtime.ts b/packages/jsx/src/jsx-runtime.ts
index 44c28800..ba659101 100644
--- a/packages/jsx/src/jsx-runtime.ts
+++ b/packages/jsx/src/jsx-runtime.ts
@@ -17,8 +17,9 @@ import type { JSX as SolidJSX } from "solid-js";
// "canvas" is dropped: a DOM canvas's content doesn't survive
// drawElementImage, so it is useless inside a paint host (draw with
-// <Surface> instead).
-type HtmlElementTags = Omit<SolidJSX.HTMLElementTags, "canvas">;
+// <Surface> instead). "audio" and "video" are dropped: media doesn't play
+// under a paint host — use the <Audio>/<Video> composition elements.
+type HtmlElementTags = Omit<SolidJSX.HTMLElementTags, "canvas" | "audio" | "video">;
export declare namespace JSX {
// Solid's Element type keeps Solid's control flow (<For>, <Show>, …) and