diff --git a/src/index.js b/src/index.js index bc3c047c7..d6f6adbe8 100644 --- a/src/index.js +++ b/src/index.js @@ -150,7 +150,8 @@ class ReactTooltip extends Component { if (!id) { targetArray = document.querySelectorAll('[data-tip]:not([data-for])') } else { - targetArray = document.querySelectorAll(`[data-tip][data-for="${id}"]`) + const escaped = id.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + targetArray = document.querySelectorAll(`[data-tip][data-for="${escaped}"]`) } // targetArray is a NodeList, convert it to a real array return nodeListToArray(targetArray)