Skip to content

Commit

Permalink
fix(Highlight): only warn once for possibly missing highlighting (alg…
Browse files Browse the repository at this point in the history
  • Loading branch information
Haroenv authored Feb 2, 2018
1 parent fdbf93f commit 7aa3126
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/vue-instantsearch/src/components/Highlight.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getPropertyByPath } from '../util/object';
import { warn } from '../util/warn';

export default {
functional: true,
Expand All @@ -20,8 +21,8 @@ export default {
const attributeValue = getPropertyByPath(result, attributePath);

if (process.env.NODE_ENV !== 'production' && attributeValue === undefined) {
throw new Error(
`The "${attributeName}" attribute is currently not configured to be highlighted in Algolia.
warn(
`The "${attributeName}" attribute might currently not be configured to be highlighted in Algolia.
See https://www.algolia.com/doc/api-reference/api-parameters/attributesToHighlight/.`
);
}
Expand Down
8 changes: 8 additions & 0 deletions packages/vue-instantsearch/src/util/warn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const cache = new Set();

export function warn(message) {
if (cache.has(message)) return;
cache.add(message);
// eslint-disable-next-line no-console
console.warn(message);
}

0 comments on commit 7aa3126

Please sign in to comment.