Skip to content

Commit f6ef9c0

Browse files
committed
add throws
1 parent ba9242d commit f6ef9c0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

web_src/js/features/codeeditor.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ export async function createMonaco(textarea: HTMLTextAreaElement, filename: stri
127127

128128
const container = document.createElement('div');
129129
container.className = 'monaco-editor-container';
130-
textarea.parentNode?.append(container);
130+
if (!textarea.parentNode) throw new Error('Parent node absent');
131+
textarea.parentNode.append(container);
131132

132133
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
133134
updateTheme(monaco);
@@ -146,7 +147,8 @@ export async function createMonaco(textarea: HTMLTextAreaElement, filename: stri
146147
]);
147148

148149
const model = editor.getModel();
149-
model?.onDidChangeContent(() => {
150+
if (!model) throw new Error('Unable to get editor model');
151+
model.onDidChangeContent(() => {
150152
textarea.value = editor.getValue({
151153
preserveBOM: true,
152154
lineEnding: '',

0 commit comments

Comments
 (0)