cssmanager: Throw if no matching style sheet is found

This avoids a later null dereference when the stack trace isn't as
useful.
This commit is contained in:
Richard Hansen 2021-03-19 15:49:33 -04:00 committed by John McLear
parent 5b05ee79ff
commit 742a7cd430
1 changed files with 3 additions and 1 deletions

View File

@ -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);