Skip to content

Commit 2621f5e

Browse files
committed
escape backslash and double quote in getTargetArray method
1 parent 8a20794 commit 2621f5e

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)