fix(ui): wrap some possible null values (#1922)

This commit is contained in:
Delirium 2024-03-01 10:51:18 +01:00 committed by GitHub
parent 2760e57d9a
commit deb9f37d8f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 8 deletions

View file

@ -43,14 +43,18 @@ export default class CanvasManager {
this.lastTs = t;
const playTime = t - this.delta
if (playTime > 0) {
const node = this.getNode(parseInt(this.nodeId, 10)) as unknown as VElement
const canvasCtx = (node.node as HTMLCanvasElement).getContext('2d');
const canvasEl = node.node as HTMLVideoElement;
if (!this.videoTag.paused) {
void this.videoTag.pause()
const node = this.getNode(parseInt(this.nodeId, 10))
if (node && node.node) {
const canvasCtx = (node.node as HTMLCanvasElement).getContext('2d');
const canvasEl = node.node as HTMLVideoElement;
if (!this.videoTag.paused) {
void this.videoTag.pause()
}
this.videoTag.currentTime = playTime/1000;
canvasCtx?.drawImage(this.videoTag, 0, 0, canvasEl.width, canvasEl.height);
} else {
console.error(`CanvasManager: Node ${this.nodeId} not found`)
}
this.videoTag.currentTime = playTime/1000;
canvasCtx?.drawImage(this.videoTag, 0, 0, canvasEl.width, canvasEl.height);
}
}
}

View file

@ -52,7 +52,7 @@ export default function (app: App | null) {
}
const nowOwning: number[] = []
const styleSheets = root.adoptedStyleSheets
if (Symbol.iterator in styleSheets) {
if (styleSheets && Symbol.iterator in styleSheets) {
for (const s of styleSheets) {
let sheetID = styleSheetIDMap.get(s)
const init = !sheetID