1
0
Fork 0

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
This commit is contained in:
Kiho Cham 2017-03-17 23:21:47 +08:00 committed by Vincent Voyer
parent 68bab4112e
commit 25dbb4d7d3

View file

@ -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);