diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 6310d299b4283..9752acb53db85 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3089,7 +3089,7 @@ namespace ts { export function isIntrinsicJsxName(name: __String | string) { const ch = (name as string).charCodeAt(0); - return (ch >= CharacterCodes.a && ch <= CharacterCodes.z) || (name as string).indexOf("-") > -1; + return (ch >= CharacterCodes.a && ch <= CharacterCodes.z) || stringContains((name as string), "-"); } function get16BitUnicodeEscapeSequence(charCode: number): string { diff --git a/src/services/services.ts b/src/services/services.ts index 27a458bf1ef5d..725decf18f242 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1542,7 +1542,7 @@ namespace ts { synchronizeHostData(); const sourceFile = getValidSourceFile(fileName); const node = getTouchingPropertyName(sourceFile, position); - if (isIdentifier(node) && isJsxOpeningElement(node.parent) || isJsxClosingElement(node.parent)) { + if (isIdentifier(node) && (isJsxOpeningElement(node.parent) || isJsxClosingElement(node.parent)) && isIntrinsicJsxName(node.escapedText)) { const { openingElement, closingElement } = node.parent.parent; return [openingElement, closingElement].map((node): RenameLocation => ({ fileName: sourceFile.fileName, textSpan: createTextSpanFromNode(node.tagName, sourceFile) })); diff --git a/tests/cases/fourslash/tsxRename4.ts b/tests/cases/fourslash/tsxRename4.ts index ac25b04800841..e46c2b7ebcbfa 100644 --- a/tests/cases/fourslash/tsxRename4.ts +++ b/tests/cases/fourslash/tsxRename4.ts @@ -1,15 +1,23 @@ /// +// @jsx: preserve + //@Filename: file.tsx ////declare module JSX { //// interface Element {} -//// interface IntrinsicElements {} +//// interface IntrinsicElements { +//// div: {}; +//// } ////} ////class [|MyClass|] {} //// ////<[|MyClass|]>; ////<[|MyClass|]/>; +//// +////<[|div|]> + +verify.noErrors(); -const [r0, r1, r2, r3] = test.ranges(); -verify.renameLocations([r0, r3], [r0, r1, r2, r3]); -verify.renameLocations([r1, r2], [r1, r2]); +const [r0, r1, r2, r3, d0, d1] = test.ranges(); +verify.rangesAreRenameLocations([r0, r1, r2, r3]); +verify.rangesAreRenameLocations([d0, d1]);