feat: add DashVideo media element (html, react) with sandbox support (#940)

This commit is contained in:
Christian Pillsbury
2026-03-16 12:21:19 -07:00
committed by GitHub
parent 7a5ce94bca
commit 5bdbbec8a0
16 changed files with 468 additions and 9 deletions
@@ -0,0 +1 @@
import '../../define/media/dash-video';
@@ -0,0 +1,14 @@
import { DashVideo } from '../../media/dash-video';
import { safeDefine } from '../safe-define';
export class DashVideoElement extends DashVideo {
static readonly tagName = 'dash-video';
}
safeDefine(DashVideoElement);
declare global {
interface HTMLElementTagNameMap {
[DashVideoElement.tagName]: DashVideoElement;
}
}
@@ -0,0 +1,32 @@
import { DashCustomMedia } from '@videojs/core/dom/media/dash';
export class DashVideo extends DashCustomMedia {
static getTemplateHTML(attrs: Record<string, string>): string {
const { src, ...rest } = attrs;
// biome-ignore lint/complexity/noThisInStatic: intentional use of super
return super.getTemplateHTML(rest);
}
constructor() {
super();
this.attach(this.target);
}
attributeChangedCallback(attrName: string, oldValue: string | null, newValue: string | null): void {
if (attrName !== 'src') {
super.attributeChangedCallback(attrName, oldValue, newValue);
}
if (attrName === 'src' && oldValue !== newValue) {
this.src = newValue ?? '';
}
}
disconnectedCallback(): void {
super.disconnectedCallback?.();
if (!this.hasAttribute('keep-alive')) {
this.destroy();
}
}
}