From b7a92591e9c0293941f60b152cd151759fabbaf1 Mon Sep 17 00:00:00 2001 From: Pishoy Girgis Date: Sun, 11 Aug 2024 19:30:38 +0200 Subject: [PATCH] [#122][Flashcards/JavaScript] Avoid an idempotent log error message. It doesn't have any impact, besides a harmless error message: ``` TypeError: Cannot read properties of null (reading 'split') ``` Still, it's cleaner to avoid it. --- flashcards/constants.py | 6 ++++-- .../output/html/a_coptic_dictionary__all_dialects/script.js | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/flashcards/constants.py b/flashcards/constants.py index 1c4523c427..c5e4dfb2c0 100644 --- a/flashcards/constants.py +++ b/flashcards/constants.py @@ -117,8 +117,10 @@ btn.classList.add('hover-link'); btn.onclick = () => { dialect(btn.innerHTML); }; }); - (new URLSearchParams(window.location.search)).get('d').split(',').forEach( - dialect); + d = (new URLSearchParams(window.location.search)).get('d'); + if (d !== undefined) { + d.split(',').forEach(dialect); + } """ CRUM_CSS = """ diff --git a/flashcards/data/output/html/a_coptic_dictionary__all_dialects/script.js b/flashcards/data/output/html/a_coptic_dictionary__all_dialects/script.js index db22d9780f..2a2d34bb64 100644 --- a/flashcards/data/output/html/a_coptic_dictionary__all_dialects/script.js +++ b/flashcards/data/output/html/a_coptic_dictionary__all_dialects/script.js @@ -101,6 +101,8 @@ window.addEventListener("load", function() { btn.classList.add('hover-link'); btn.onclick = () => { dialect(btn.innerHTML); }; }); - (new URLSearchParams(window.location.search)).get('d').split(',').forEach( - dialect); + d = (new URLSearchParams(window.location.search)).get('d'); + if (d !== undefined) { + d.split(',').forEach(dialect); + } });