Skip to content

Commit

Permalink
Prevent closing tags after self-closing JSX tags
Browse files Browse the repository at this point in the history
FIX: Fix a bug that would cause self-closing JSX tags to have another
closing tag inserted when typing the final '>'.

Closes codemirror/dev#1339
  • Loading branch information
marijnh committed Feb 20, 2024
1 parent ee3752b commit 2ad959e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/javascript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export const autoCloseTags = EditorView.inputHandler.of((view, from, to, text, d
}
} else if (text == ">") {
let openTag = findOpenTag(around)
if (openTag &&
if (openTag && openTag.name == "JSXOpenTag" &&
!/^\/?>|^<\//.test(state.doc.sliceString(head, head + 2)) &&
(name = elementName(state.doc, openTag, head)))
return {range, changes: {from: head, insert: `</${name}>`}}
Expand Down

0 comments on commit 2ad959e

Please sign in to comment.