fix(playback): guard Video.js Tech access

This commit is contained in:
4gray committed 2026-07-31 08:40:33 +02:00
1 parent 877d632255
commit 4952f3b8aa
2 files changed
+7 -2

No files matched your search

@@ -32,11 +32,16 @@ describe('getVideoJsTechVideo', () => {
describe('hasActiveVhsSourceHandler', () => {
it('detects the documented Video.js Tech VHS runtime property', () => {
const tech = jest.fn(() => ({ vhs: {} }));
expect(
hasActiveVhsSourceHandler({
tech: () => ({ vhs: {} }),
tech,
} as unknown as VideoJsPlayer)
).toBe(true);
expect(tech).toHaveBeenCalledWith({
IWillNotUseThisInPlugins: true,
});
expect(
hasActiveVhsSourceHandler({
tech: () => ({ el: () => document.createElement('video') }),
@@ -102,7 +102,7 @@ export function hasActiveVhsSourceHandler(
player: Pick<VideoJsPlayer, 'tech'>
): boolean {
try {
const vhs = player.tech()?.vhs;
const vhs = player.tech({ IWillNotUseThisInPlugins: true })?.vhs;
return typeof vhs === 'object' && vhs !== null;
} catch {
return false;