Skip to content
This repository was archived by the owner on Nov 25, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/token_position.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ describe('token_positions', () => {
}
}
})

it('does not change the text', () => {
const text = 'fmt.Sprintf("%5d", someVar)'
const elem = dom.createElementFromString(text)

convertNode(elem)

expect(elem.textContent).to.equal(text)
})
})

describe('findElementWithOffset()', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/token_position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export function convertNode(parentNode: HTMLElement): void {
const isLastNode = i === parentNode.childNodes.length - 1

if (node.nodeType === Node.TEXT_NODE) {
let nodeText = unescape(node.textContent || '')
let nodeText = node.textContent || ''
if (nodeText === '') {
continue
}
Expand Down Expand Up @@ -160,7 +160,7 @@ const enum TokenType {
* @param node The node containing the token.
*/
function getTokenType(node: Node): TokenType {
const text = unescape(node.textContent || '')
const text = node.textContent || ''
if (text.length === 0) {
return TokenType.Other
}
Expand Down