instantsearch.js 4.37.2 → 4.37.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.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## [4.37.3](https://github.com/algolia/instantsearch.js/compare/v4.37.2...v4.37.3) (2022-01-25)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **helpers:** display warning if attribute cannot be highlighted/snippeted ([#4996](https://github.com/algolia/instantsearch.js/issues/4996)) ([e81bf59](https://github.com/algolia/instantsearch.js/commit/e81bf59f0f28eb7b9f54f7d4424c60546b9a4d8c))
7
+
8
+
9
+
1
10
  ## [4.37.2](https://github.com/algolia/instantsearch.js/compare/v4.37.1...v4.37.2) (2022-01-10)
2
11
 
3
12
 
@@ -94,6 +94,9 @@ var connectBreadcrumb = function connectBreadcrumb(renderFn) {
94
94
  state = _ref2.state;
95
95
 
96
96
  function getItems() {
97
+ // The hierarchicalFacets condition is required for flavors
98
+ // that render immediately with empty results, without relying
99
+ // on init() (like React InstantSearch Hooks).
97
100
  if (!results || state.hierarchicalFacets.length === 0) {
98
101
  return [];
99
102
  }
@@ -18,8 +18,11 @@ function highlight(_ref) {
18
18
  hit = _ref.hit,
19
19
  _ref$cssClasses = _ref.cssClasses,
20
20
  cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses;
21
+ var highlightAttributeResult = (0, _index.getPropertyByPath)(hit._highlightResult, attribute); // @MAJOR fallback to attribute value if highlight is not found
21
22
 
22
- var _ref2 = (0, _index.getPropertyByPath)(hit._highlightResult, attribute) || {},
23
+ process.env.NODE_ENV === 'development' ? (0, _index.warning)(highlightAttributeResult, "Could not enable highlight for \"".concat(attribute, "\", will display an empty string.\nPlease check whether this attribute exists and is either searchable or specified in `attributesToHighlight`.\n\nSee: https://alg.li/highlighting\n")) : void 0;
24
+
25
+ var _ref2 = highlightAttributeResult || {},
23
26
  _ref2$value = _ref2.value,
24
27
  attributeValue = _ref2$value === void 0 ? '' : _ref2$value; // cx is not used, since it would be bundled as a dependency for Vue & Angular
25
28
 
@@ -18,8 +18,11 @@ function reverseHighlight(_ref) {
18
18
  hit = _ref.hit,
19
19
  _ref$cssClasses = _ref.cssClasses,
20
20
  cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses;
21
+ var highlightAttributeResult = (0, _index.getPropertyByPath)(hit._highlightResult, attribute); // @MAJOR fallback to attribute value if highlight is not found
21
22
 
22
- var _ref2 = (0, _index.getPropertyByPath)(hit._highlightResult, attribute) || {},
23
+ process.env.NODE_ENV === 'development' ? (0, _index.warning)(highlightAttributeResult, "Could not enable reverse highlight for \"".concat(attribute, "\", will display an empty string.\nPlease check whether this attribute exists and is either searchable or specified in `attributesToHighlight`.\n\nSee: https://alg.li/highlighting\n")) : void 0;
24
+
25
+ var _ref2 = highlightAttributeResult || {},
23
26
  _ref2$value = _ref2.value,
24
27
  attributeValue = _ref2$value === void 0 ? '' : _ref2$value; // cx is not used, since it would be bundled as a dependency for Vue & Angular
25
28
 
@@ -18,8 +18,11 @@ function reverseSnippet(_ref) {
18
18
  hit = _ref.hit,
19
19
  _ref$cssClasses = _ref.cssClasses,
20
20
  cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses;
21
+ var snippetAttributeResult = (0, _index.getPropertyByPath)(hit._snippetResult, attribute); // @MAJOR fallback to attribute value if snippet is not found
21
22
 
22
- var _ref2 = (0, _index.getPropertyByPath)(hit._snippetResult, attribute) || {},
23
+ process.env.NODE_ENV === 'development' ? (0, _index.warning)(snippetAttributeResult, "Could not enable reverse snippet for \"".concat(attribute, "\", will display an empty string.\nPlease check whether this attribute exists and is specified in `attributesToSnippet`.\n\nSee: https://alg.li/highlighting\n")) : void 0;
24
+
25
+ var _ref2 = snippetAttributeResult || {},
23
26
  _ref2$value = _ref2.value,
24
27
  attributeValue = _ref2$value === void 0 ? '' : _ref2$value; // cx is not used, since it would be bundled as a dependency for Vue & Angular
25
28
 
@@ -18,8 +18,11 @@ function snippet(_ref) {
18
18
  hit = _ref.hit,
19
19
  _ref$cssClasses = _ref.cssClasses,
20
20
  cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses;
21
+ var snippetAttributeResult = (0, _index.getPropertyByPath)(hit._snippetResult, attribute); // @MAJOR fallback to attribute value if snippet is not found
21
22
 
22
- var _ref2 = (0, _index.getPropertyByPath)(hit._snippetResult, attribute) || {},
23
+ process.env.NODE_ENV === 'development' ? (0, _index.warning)(snippetAttributeResult, "Could not enable snippet for \"".concat(attribute, "\", will display an empty string.\nPlease check whether this attribute exists and is specified in `attributesToSnippet`.\n\nSee: https://alg.li/highlighting\n")) : void 0;
24
+
25
+ var _ref2 = snippetAttributeResult || {},
23
26
  _ref2$value = _ref2.value,
24
27
  attributeValue = _ref2$value === void 0 ? '' : _ref2$value; // cx is not used, since it would be bundled as a dependency for Vue & Angular
25
28
 
@@ -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.2';
7
+ var _default = '4.37.3';
8
8
  exports.default = _default;
@@ -1,4 +1,4 @@
1
- /*! InstantSearch.js 4.37.2 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch.js */
1
+ /*! InstantSearch.js 4.37.3 | © 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.2';
8486
+ var version$1 = '4.37.3';
8487
8487
 
8488
8488
  var NAMESPACE = 'ais';
8489
8489
  var component = function component(componentName) {
@@ -8506,8 +8506,11 @@
8506
8506
  hit = _ref.hit,
8507
8507
  _ref$cssClasses = _ref.cssClasses,
8508
8508
  cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses;
8509
+ var highlightAttributeResult = getPropertyByPath(hit._highlightResult, attribute); // @MAJOR fallback to attribute value if highlight is not found
8509
8510
 
8510
- var _ref2 = getPropertyByPath(hit._highlightResult, attribute) || {},
8511
+ _warning(highlightAttributeResult, "Could not enable highlight for \"".concat(attribute, "\", will display an empty string.\nPlease check whether this attribute exists and is either searchable or specified in `attributesToHighlight`.\n\nSee: https://alg.li/highlighting\n")) ;
8512
+
8513
+ var _ref2 = highlightAttributeResult || {},
8511
8514
  _ref2$value = _ref2.value,
8512
8515
  attributeValue = _ref2$value === void 0 ? '' : _ref2$value; // cx is not used, since it would be bundled as a dependency for Vue & Angular
8513
8516
 
@@ -8526,8 +8529,11 @@
8526
8529
  hit = _ref.hit,
8527
8530
  _ref$cssClasses = _ref.cssClasses,
8528
8531
  cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses;
8532
+ var highlightAttributeResult = getPropertyByPath(hit._highlightResult, attribute); // @MAJOR fallback to attribute value if highlight is not found
8533
+
8534
+ _warning(highlightAttributeResult, "Could not enable reverse highlight for \"".concat(attribute, "\", will display an empty string.\nPlease check whether this attribute exists and is either searchable or specified in `attributesToHighlight`.\n\nSee: https://alg.li/highlighting\n")) ;
8529
8535
 
8530
- var _ref2 = getPropertyByPath(hit._highlightResult, attribute) || {},
8536
+ var _ref2 = highlightAttributeResult || {},
8531
8537
  _ref2$value = _ref2.value,
8532
8538
  attributeValue = _ref2$value === void 0 ? '' : _ref2$value; // cx is not used, since it would be bundled as a dependency for Vue & Angular
8533
8539
 
@@ -8547,8 +8553,11 @@
8547
8553
  hit = _ref.hit,
8548
8554
  _ref$cssClasses = _ref.cssClasses,
8549
8555
  cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses;
8556
+ var snippetAttributeResult = getPropertyByPath(hit._snippetResult, attribute); // @MAJOR fallback to attribute value if snippet is not found
8550
8557
 
8551
- var _ref2 = getPropertyByPath(hit._snippetResult, attribute) || {},
8558
+ _warning(snippetAttributeResult, "Could not enable snippet for \"".concat(attribute, "\", will display an empty string.\nPlease check whether this attribute exists and is specified in `attributesToSnippet`.\n\nSee: https://alg.li/highlighting\n")) ;
8559
+
8560
+ var _ref2 = snippetAttributeResult || {},
8552
8561
  _ref2$value = _ref2.value,
8553
8562
  attributeValue = _ref2$value === void 0 ? '' : _ref2$value; // cx is not used, since it would be bundled as a dependency for Vue & Angular
8554
8563
 
@@ -8567,8 +8576,11 @@
8567
8576
  hit = _ref.hit,
8568
8577
  _ref$cssClasses = _ref.cssClasses,
8569
8578
  cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses;
8579
+ var snippetAttributeResult = getPropertyByPath(hit._snippetResult, attribute); // @MAJOR fallback to attribute value if snippet is not found
8580
+
8581
+ _warning(snippetAttributeResult, "Could not enable reverse snippet for \"".concat(attribute, "\", will display an empty string.\nPlease check whether this attribute exists and is specified in `attributesToSnippet`.\n\nSee: https://alg.li/highlighting\n")) ;
8570
8582
 
8571
- var _ref2 = getPropertyByPath(hit._snippetResult, attribute) || {},
8583
+ var _ref2 = snippetAttributeResult || {},
8572
8584
  _ref2$value = _ref2.value,
8573
8585
  attributeValue = _ref2$value === void 0 ? '' : _ref2$value; // cx is not used, since it would be bundled as a dependency for Vue & Angular
8574
8586
 
@@ -13931,6 +13943,9 @@
13931
13943
  state = _ref2.state;
13932
13944
 
13933
13945
  function getItems() {
13946
+ // The hierarchicalFacets condition is required for flavors
13947
+ // that render immediately with empty results, without relying
13948
+ // on init() (like React InstantSearch Hooks).
13934
13949
  if (!results || state.hierarchicalFacets.length === 0) {
13935
13950
  return [];
13936
13951
  }