From 742a7cd4300144cd213182e4b2a9b19dae8588c1 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Fri, 19 Mar 2021 15:49:33 -0400 Subject: [PATCH] cssmanager: Throw if no matching style sheet is found This avoids a later null dereference when the stack trace isn't as useful. --- src/static/js/cssmanager.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/static/js/cssmanager.js b/src/static/js/cssmanager.js index 9d6f277e..b7af85d4 100644 --- a/src/static/js/cssmanager.js +++ b/src/static/js/cssmanager.js @@ -43,7 +43,9 @@ const makeCSSManager = (emptyStylesheetTitle, doc) => { for (const s of win.document.styleSheets) { if (s.title === title) return s; } - return null; + const err = new Error(`no sheet with title ${title} in doc ${doc}`) + console.error(err); + throw err; }; const browserSheet = getSheetByTitle(emptyStylesheetTitle);