Skip to content

Commit 6016ade

Browse files
Add error handling for waitForStyle.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 958ab10 commit 6016ade

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

js/replace-dom.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@ const waitForStyle = (property: string): Promise<string> => {
4040
};
4141

4242
const replaceProc = async (imageObjectArray: ImageObject[]): Promise<void> => {
43-
const scheme = await waitForStyle('--color-scheme');
43+
let scheme: string;
44+
try {
45+
scheme = await waitForStyle('--color-scheme');
46+
} catch (error) {
47+
console.error('Failed to get color scheme:', error);
48+
scheme = 'light'; // fallback to light theme
49+
}
4450

4551
for (const x of imageObjectArray) {
4652
const elm = document.getElementById(x.id);

0 commit comments

Comments
 (0)