Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't try to get canvas context on null canvas elements #565

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/components/widgets/Attitude.vue
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,7 @@ const angleY = (angle: number): number => {
}

const renderCanvas = (): void => {
if (canvasRef.value === undefined) {
console.error('Canvas ref undefined!')
return
}
if (canvasRef.value === undefined || canvasRef.value === null) return
if (canvasContext.value === undefined) {
console.warn('Canvas context undefined!')
canvasContext.value = canvasRef.value.getContext('2d')
Expand Down
2 changes: 1 addition & 1 deletion src/components/widgets/Compass.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const smallestDimension = computed(() => (width.value < height.value ? width.val

// Renders the updated canvas state
const renderCanvas = (): void => {
if (canvasRef.value === undefined) return
if (canvasRef.value === undefined || canvasRef.value === null) return
if (canvasContext.value === undefined) canvasContext.value = canvasRef.value.getContext('2d')
const ctx = canvasContext.value
resetCanvas(ctx)
Expand Down
5 changes: 1 addition & 4 deletions src/components/widgets/CompassHUD.vue
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,7 @@ const angleX = (angle: number): number => {
const canvasRef = ref<HTMLCanvasElement | undefined>()
const canvasContext = ref()
const renderCanvas = (): void => {
if (canvasRef.value === undefined) {
console.error('Canvas ref undefined!')
return
}
if (canvasRef.value === undefined || canvasRef.value === null) return
if (canvasContext.value === undefined) {
console.warn('Canvas context undefined!')
canvasContext.value = canvasRef.value.getContext('2d')
Expand Down
5 changes: 1 addition & 4 deletions src/components/widgets/DepthHUD.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,7 @@ const distanceY = (altitude: number): number => {
const canvasRef = ref<HTMLCanvasElement | undefined>()
const canvasContext = ref()
const renderCanvas = (): void => {
if (canvasRef.value === undefined) {
console.error('Canvas ref undefined!')
return
}
if (canvasRef.value === undefined || canvasRef.value === null) return
if (canvasContext.value === undefined) {
console.warn('Canvas context undefined!')
canvasContext.value = canvasRef.value.getContext('2d')
Expand Down
2 changes: 1 addition & 1 deletion src/components/widgets/VirtualHorizon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const smallestDimension = computed(() => (width.value < height.value ? width.val

// Renders the updated canvas state
const renderCanvas = (): void => {
if (canvasRef.value === undefined) return
if (canvasRef.value === undefined || canvasRef.value === null) return
if (canvasContext.value === undefined) canvasContext.value = canvasRef.value.getContext('2d')
const ctx = canvasContext.value
resetCanvas(ctx)
Expand Down