Use canvas instead of div container for calculating the game size

This commit is contained in:
Paul Bottein 2021-01-27 12:38:57 +01:00
parent b7b2934106
commit b52c546a8c
2 changed files with 10 additions and 1 deletions

View file

@ -7,6 +7,15 @@ export class HtmlUtils {
throw new Error("Cannot find HTML element with id '"+id+"'");
}
public static querySelectorOrFail<T extends HTMLElement>(selector: string): T {
const elem = document.querySelector(selector);
if (elem === null) {
throw new Error("Cannot find HTML element with selector '"+selector+"'");
}
// FIXME: does not check the type of the returned type
return elem as T;
}
public static removeElementByIdOrFail<T extends HTMLElement>(id: string): T {
const elem = document.getElementById(id);
if (HtmlUtils.isHtmlElement<T>(elem)) {