From 2621f5e43f414830219601e334a20bc2f5ad9d39 Mon Sep 17 00:00:00 2001 From: rnons Date: Thu, 8 Dec 2016 23:49:42 +0800 Subject: [PATCH] escape backslash and double quote in getTargetArray method --- src/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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)