Skip to content

Commit f736d17

Browse files
authored
Fix validating empty html string (exercism#7855)
1 parent 8b3fbd7 commit f736d17

File tree

1 file changed

+11
-8
lines changed
  • app/javascript/components/bootcamp/FrontendExercisePage/LHS

1 file changed

+11
-8
lines changed

app/javascript/components/bootcamp/FrontendExercisePage/LHS/LHS.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,17 @@ export function LHS() {
5757
if (!jsEditorRef.current || !htmlEditorRef.current) return
5858

5959
const htmlText = htmlEditorRef.current.state.doc.toString()
60-
const isHTMLValid = validateHtml(htmlText)
61-
62-
if (!isHTMLValid.isValid) {
63-
setTab('html')
64-
toast.error(
65-
`Your HTML is invalid. Please check the linter and look for unclosed tags.`
66-
)
67-
return
60+
61+
if (htmlText.length > 0) {
62+
const isHTMLValid = validateHtml(htmlText)
63+
64+
if (!isHTMLValid.isValid) {
65+
setTab('html')
66+
toast.error(
67+
`Your HTML is invalid. Please check the linter and look for unclosed tags.`
68+
)
69+
return
70+
}
6871
}
6972

7073
const jsView = jsEditorRef.current

0 commit comments

Comments
 (0)