mirror of
https://github.com/zoriya/v10.git
synced 2026-08-09 07:37:48 +00:00
feat: add DashVideo media element (html, react) with sandbox support (#940)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user