Skip to content

Commit a030f50

Browse files
authored
Merge pull request #236 from rnons/patch-1
escape backslash in getTargetArray method
2 parents 8a20794 + 2621f5e commit a030f50

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ class ReactTooltip extends Component {
150150
if (!id) {
151151
targetArray = document.querySelectorAll('[data-tip]:not([data-for])')
152152
} else {
153-
targetArray = document.querySelectorAll(`[data-tip][data-for="${id}"]`)
153+
const escaped = id.replace(/\\/g, '\\\\').replace(/"/g, '\\"')
154+
targetArray = document.querySelectorAll(`[data-tip][data-for="${escaped}"]`)
154155
}
155156
// targetArray is a NodeList, convert it to a real array
156157
return nodeListToArray(targetArray)

0 commit comments

Comments
 (0)