From fe9817ab5e1973ff6c81e88a449ef0cb49ed2aa9 Mon Sep 17 00:00:00 2001 From: w3bdesign <45217974+w3bdesign@users.noreply.github.com> Date: Fri, 22 Apr 2022 01:04:29 +0200 Subject: [PATCH] Fiks "Object may be null" --- scripts/classes/ProcessInputForm/classProcessInputForm.ts | 6 +++++- scripts/classes/ValidText/classValidText.ts | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/classes/ProcessInputForm/classProcessInputForm.ts b/scripts/classes/ProcessInputForm/classProcessInputForm.ts index 84a7cb6..b0f3744 100644 --- a/scripts/classes/ProcessInputForm/classProcessInputForm.ts +++ b/scripts/classes/ProcessInputForm/classProcessInputForm.ts @@ -57,7 +57,11 @@ export default class classProcessInputForm { * @param {string} value Value that we modify with */ private static setInnerHTML(elementId: string, value: string) { - window.document.getElementById(elementId).innerHTML = value; + const element = window.document.getElementById(elementId); + + if (element && value) { + element.innerHTML = value; + } } /** diff --git a/scripts/classes/ValidText/classValidText.ts b/scripts/classes/ValidText/classValidText.ts index f17d34c..511a63a 100644 --- a/scripts/classes/ValidText/classValidText.ts +++ b/scripts/classes/ValidText/classValidText.ts @@ -23,9 +23,9 @@ export default class classValidText { bilInformasjon !== undefined && bilInformasjon.length === 7 ) { - submitButton.removeAttribute("disabled"); + submitButton?.removeAttribute("disabled"); } else { - submitButton.setAttribute("disabled", "true"); + submitButton?.setAttribute("disabled", "true"); } }; }