instantsearch.js 4.37.0 → 4.37.1

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.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## [4.37.1](https://github.com/algolia/instantsearch.js/compare/v4.37.0...v4.37.1) (2022-01-05)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **connectBreadcrumb:** returns an empty array if no hierarchicalFacets exist ([#4980](https://github.com/algolia/instantsearch.js/issues/4980)) ([3ea9b91](https://github.com/algolia/instantsearch.js/commit/3ea9b918f85c686a07b06cfc12b8c59b80181f28))
7
+ * **es:** mark inner package.json as side-effect free ([#4984](https://github.com/algolia/instantsearch.js/issues/4984)) ([74f56f3](https://github.com/algolia/instantsearch.js/commit/74f56f35b7ccc78904592edfc40e782e40847986)), closes [#4971](https://github.com/algolia/instantsearch.js/issues/4971)
8
+ * **events:** emit error as typeof Error ([#4983](https://github.com/algolia/instantsearch.js/issues/4983)) ([4adfaf2](https://github.com/algolia/instantsearch.js/commit/4adfaf2eba40fffa7f4800664dc89e0edf2d819e))
9
+
10
+
11
+
1
12
  # [4.37.0](https://github.com/algolia/instantsearch.js/compare/v4.36.0...v4.37.0) (2022-01-04)
2
13
 
3
14
 
@@ -57,7 +57,9 @@ var connectBreadcrumb = function connectBreadcrumb(renderFn) {
57
57
  if (!facetValue) {
58
58
  var breadcrumb = state.getHierarchicalFacetBreadcrumb(hierarchicalFacetName);
59
59
 
60
- if (breadcrumb.length > 0) {
60
+ if (breadcrumb.length === 0) {
61
+ return state;
62
+ } else {
61
63
  return state.resetPage().toggleFacetRefinement(hierarchicalFacetName, breadcrumb[0]);
62
64
  }
63
65
  }
@@ -92,7 +94,7 @@ var connectBreadcrumb = function connectBreadcrumb(renderFn) {
92
94
  state = _ref2.state;
93
95
 
94
96
  function getItems() {
95
- if (!results) {
97
+ if (!results || state.hierarchicalFacets.length === 0) {
96
98
  return [];
97
99
  }
98
100
 
@@ -446,10 +446,15 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
446
446
 
447
447
  mainHelper.on('error', function (_ref4) {
448
448
  var error = _ref4.error;
449
-
450
- _this3.emit('error', {
451
- error: error
452
- });
449
+ // If an error is emitted, it is re-thrown by events. In previous versions
450
+ // we emitted {error}, which is thrown as:
451
+ // "Uncaught, unspecified \"error\" event. ([object Object])"
452
+ // To avoid breaking changes, we make the error available in both
453
+ // `error` and `error.error`
454
+ // @MAJOR emit only error
455
+ error.error = error;
456
+
457
+ _this3.emit('error', error);
453
458
  });
454
459
  this.mainHelper = mainHelper;
455
460
  this.middleware.forEach(function (_ref5) {
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _default = '4.37.0';
7
+ var _default = '4.37.1';
8
8
  exports.default = _default;
@@ -1,4 +1,4 @@
1
- /*! InstantSearch.js 4.37.0 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch.js */
1
+ /*! InstantSearch.js 4.37.1 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch.js */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -8483,7 +8483,7 @@
8483
8483
  instantSearchInstance.renderState = _objectSpread2(_objectSpread2({}, instantSearchInstance.renderState), {}, _defineProperty({}, parentIndexName, _objectSpread2(_objectSpread2({}, instantSearchInstance.renderState[parentIndexName]), renderState)));
8484
8484
  }
8485
8485
 
8486
- var version$1 = '4.37.0';
8486
+ var version$1 = '4.37.1';
8487
8487
 
8488
8488
  var NAMESPACE = 'ais';
8489
8489
  var component = function component(componentName) {
@@ -10314,10 +10314,15 @@
10314
10314
 
10315
10315
  mainHelper.on('error', function (_ref4) {
10316
10316
  var error = _ref4.error;
10317
-
10318
- _this3.emit('error', {
10319
- error: error
10320
- });
10317
+ // If an error is emitted, it is re-thrown by events. In previous versions
10318
+ // we emitted {error}, which is thrown as:
10319
+ // "Uncaught, unspecified \"error\" event. ([object Object])"
10320
+ // To avoid breaking changes, we make the error available in both
10321
+ // `error` and `error.error`
10322
+ // @MAJOR emit only error
10323
+ error.error = error;
10324
+
10325
+ _this3.emit('error', error);
10321
10326
  });
10322
10327
  this.mainHelper = mainHelper;
10323
10328
  this.middleware.forEach(function (_ref5) {
@@ -13899,7 +13904,9 @@
13899
13904
  if (!facetValue) {
13900
13905
  var breadcrumb = state.getHierarchicalFacetBreadcrumb(hierarchicalFacetName);
13901
13906
 
13902
- if (breadcrumb.length > 0) {
13907
+ if (breadcrumb.length === 0) {
13908
+ return state;
13909
+ } else {
13903
13910
  return state.resetPage().toggleFacetRefinement(hierarchicalFacetName, breadcrumb[0]);
13904
13911
  }
13905
13912
  }
@@ -13934,7 +13941,7 @@
13934
13941
  state = _ref2.state;
13935
13942
 
13936
13943
  function getItems() {
13937
- if (!results) {
13944
+ if (!results || state.hierarchicalFacets.length === 0) {
13938
13945
  return [];
13939
13946
  }
13940
13947