algoliasearch-helper 3.11.2 → 3.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ 3.11.3 - 2023-01-23
2
+ * chore(tests): remove remaining lodash usage (#927) https://github.com/algolia/algoliasearch-helper-js/commit/e234837aaa10e6458d06085ff9938c741ee74d4b
3
+ * fix(getFacetValues): reflect the value of _state in hierarchicalFacetValues (#925) https://github.com/algolia/algoliasearch-helper-js/commit/4d093b464e62dc6963dc6676aee19ff78145f48a
4
+ * test(integration): refactor to speed up (#926) https://github.com/algolia/algoliasearch-helper-js/commit/2c9ffeb23d68a09ac78a29d2a53024d9f724d525
5
+
1
6
  3.11.2 - 2023-01-09
2
7
  * feat: update Algolia logo (#918) https://github.com/algolia/algoliasearch-helper-js/commit/58e0e588195dde8f411383ad248bd112a9c01eb5
3
8
  * fix: prevent prototype pollution in rare error-cases (#923) https://github.com/algolia/algoliasearch-helper-js/commit/7ae16eaa3f5732b96f1fa40973778c5494e77b89, closes https://github.com/algolia/algoliasearch-helper-js/issues/922
@@ -2953,7 +2953,33 @@ function extractNormalizedFacetValues(results, attribute) {
2953
2953
  };
2954
2954
  });
2955
2955
  } else if (results._state.isHierarchicalFacet(attribute)) {
2956
- return find(results.hierarchicalFacets, predicate);
2956
+ var hierarchicalFacetValues = find(results.hierarchicalFacets, predicate);
2957
+ if (!hierarchicalFacetValues) return hierarchicalFacetValues;
2958
+
2959
+ var hierarchicalFacet = results._state.getHierarchicalFacetByName(attribute);
2960
+ var currentRefinementSplit = unescapeFacetValue(
2961
+ results._state.getHierarchicalRefinement(attribute)[0] || ''
2962
+ ).split(results._state._getHierarchicalFacetSeparator(hierarchicalFacet));
2963
+ currentRefinementSplit.unshift(attribute);
2964
+
2965
+ setIsRefined(hierarchicalFacetValues, currentRefinementSplit, 0);
2966
+
2967
+ return hierarchicalFacetValues;
2968
+ }
2969
+ }
2970
+
2971
+ /**
2972
+ * Set the isRefined of a hierarchical facet result based on the current state.
2973
+ * @param {SearchResults.HierarchicalFacet} item Hierarchical facet to fix
2974
+ * @param {string[]} currentRefinementSplit array of parts of the current hierarchical refinement
2975
+ * @param {number} depth recursion depth in the currentRefinement
2976
+ */
2977
+ function setIsRefined(item, currentRefinement, depth) {
2978
+ item.isRefined = item.name === currentRefinement[depth];
2979
+ if (item.data) {
2980
+ item.data.forEach(function(child) {
2981
+ setIsRefined(child, currentRefinement, depth + 1);
2982
+ });
2957
2983
  }
2958
2984
  }
2959
2985
 
@@ -5590,7 +5616,7 @@ module.exports = function isValidUserToken(userToken) {
5590
5616
  },{}],24:[function(require,module,exports){
5591
5617
  'use strict';
5592
5618
 
5593
- module.exports = '3.11.2';
5619
+ module.exports = '3.11.3';
5594
5620
 
5595
5621
  },{}]},{},[1])(1)
5596
5622
  });