Skip to content

Commit 0b2d4af

Browse files
authored
fix: rawContent was not correctly cloned (hence undefined) (#6549)
* fix: rawContent was not correctly cloned (hence undefined) * chore: more performant cloning
1 parent ea8a648 commit 0b2d4af

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎packages/algoliasearch-helper/src/algoliasearch.helper.js‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,8 +1844,11 @@ AlgoliaSearchHelper.prototype._dispatchAlgoliaResponse = function (
18441844
if (this._currentNbQueries === 0) this.emit('searchQueueEmpty');
18451845

18461846
var results = content.results.slice();
1847-
var rawContent = Object.create(content);
1848-
delete rawContent.results;
1847+
var rawContent = Object.keys(content).reduce(function (value, key) {
1848+
if (key !== 'results') value[key] = content[key];
1849+
return value;
1850+
}, {});
1851+
18491852
if (Object.keys(rawContent).length <= 0) {
18501853
rawContent = undefined;
18511854
}
@@ -1869,12 +1872,11 @@ AlgoliaSearchHelper.prototype._dispatchAlgoliaResponse = function (
18691872
specificResults,
18701873
self._searchResultsOptions
18711874
);
1872-
helper.lastResults._rawContent = rawContent;
1875+
if (rawContent !== undefined) helper.lastResults._rawContent = rawContent;
18731876

18741877
helper.emit('result', {
18751878
results: helper.lastResults,
18761879
state: state,
1877-
_rawContent: rawContent,
18781880
});
18791881
});
18801882
};

0 commit comments

Comments
 (0)