From 25dbb4d7d31d54e3e21353422ef6497aa4495eaf Mon Sep 17 00:00:00 2001 From: Kiho Cham Date: Fri, 17 Mar 2017 23:21:47 +0800 Subject: [PATCH] avoid the native Object's properties (#172) the given data type of docsearch hits might be conflict with the properties of the native Object, such as the constructor, so we need to do this check --- src/lib/utils.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/utils.js b/src/lib/utils.js index b2b8881c..b4b7e479 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -74,7 +74,9 @@ let utils = { if (typeof key === 'string') { key = key.toLowerCase(); } - if (!newCollection[key]) { + // fix #171 the given data type of docsearch hits might be conflict with the properties of the native Object, + // such as the constructor, so we need to do this check. + if (!Object.prototype.hasOwnProperty.call(newCollection, key)) { newCollection[key] = []; } newCollection[key].push(item);