Skip to content

Commit 50bb676

Browse files
committed
fix(helpers): deprecate highlight helpers
These are superseded by the components in html tagged templates
1 parent 3a173b7 commit 50bb676

File tree

5 files changed

+45
-0
lines changed

5 files changed

+45
-0
lines changed

packages/instantsearch.js/src/helpers/highlight.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,22 @@ export type HighlightOptions = {
1515

1616
const suit = component('Highlight');
1717

18+
/**
19+
* @deprecated use html tagged templates and the Highlight component instead
20+
*/
1821
export default function highlight({
1922
attribute,
2023
highlightedTagName = 'mark',
2124
hit,
2225
cssClasses = {},
2326
}: HighlightOptions): string {
27+
warning(
28+
false,
29+
`\`instantsearch.highlight\` function has been deprecated. It is still supported in 4.x releases, but not further. It is replaced by the \`Highlight\` component.
30+
31+
For more information, visit https://www.algolia.com/doc/guides/building-search-ui/upgrade-guides/js/?client=html+tagged+templates#upgrade-templates`
32+
);
33+
2434
const highlightAttributeResult = getPropertyByPath(
2535
hit._highlightResult,
2636
attribute

packages/instantsearch.js/src/helpers/reverseHighlight.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,22 @@ export type ReverseHighlightOptions = {
2222

2323
const suit = component('ReverseHighlight');
2424

25+
/**
26+
* @deprecated use html tagged templates and the ReverseHighlight component instead
27+
*/
2528
export default function reverseHighlight({
2629
attribute,
2730
highlightedTagName = 'mark',
2831
hit,
2932
cssClasses = {},
3033
}: ReverseHighlightOptions): string {
34+
warning(
35+
false,
36+
`\`instantsearch.reverseHighlight\` function has been deprecated. It is still supported in 4.x releases, but not further. It is replaced by the \`ReverseHighlight\` component.
37+
38+
For more information, visit https://www.algolia.com/doc/guides/building-search-ui/upgrade-guides/js/?client=html+tagged+templates#upgrade-templates`
39+
);
40+
3141
const highlightAttributeResult = getPropertyByPath(
3242
hit._highlightResult,
3343
attribute

packages/instantsearch.js/src/helpers/reverseSnippet.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,22 @@ export type ReverseSnippetOptions = {
2222

2323
const suit = component('ReverseSnippet');
2424

25+
/**
26+
* @deprecated use html tagged templates and the ReverseSnippet component instead
27+
*/
2528
export default function reverseSnippet({
2629
attribute,
2730
highlightedTagName = 'mark',
2831
hit,
2932
cssClasses = {},
3033
}: ReverseSnippetOptions): string {
34+
warning(
35+
false,
36+
`\`instantsearch.reverseSnippet\` function has been deprecated. It is still supported in 4.x releases, but not further. It is replaced by the \`ReverseSnippet\` component.
37+
38+
For more information, visit https://www.algolia.com/doc/guides/building-search-ui/upgrade-guides/js/?client=html+tagged+templates#upgrade-templates`
39+
);
40+
3141
const snippetAttributeResult = getPropertyByPath(
3242
hit._snippetResult,
3343
attribute

packages/instantsearch.js/src/helpers/snippet.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,22 @@ export type SnippetOptions = {
1515

1616
const suit = component('Snippet');
1717

18+
/**
19+
* @deprecated use html tagged templates and the Snippet component instead
20+
*/
1821
export default function snippet({
1922
attribute,
2023
highlightedTagName = 'mark',
2124
hit,
2225
cssClasses = {},
2326
}: SnippetOptions): string {
27+
warning(
28+
false,
29+
`\`instantsearch.snippet\` function has been deprecated. It is still supported in 4.x releases, but not further. It is replaced by the \`Snippet\` component.
30+
31+
For more information, visit https://www.algolia.com/doc/guides/building-search-ui/upgrade-guides/js/?client=html+tagged+templates#upgrade-templates`
32+
);
33+
2434
const snippetAttributeResult = getPropertyByPath(
2535
hit._snippetResult,
2636
attribute

packages/instantsearch.js/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,14 @@ type InstantSearchModule = {
2525
stateMappings: typeof stateMappings;
2626

2727
createInfiniteHitsSessionStorageCache: typeof createInfiniteHitsSessionStorageCache;
28+
29+
/** @deprecated use html tagged templates and the Highlight component instead */
2830
highlight: typeof helpers.highlight;
31+
/** @deprecated use html tagged templates and the ReverseHighlight component instead */
2932
reverseHighlight: typeof helpers.reverseHighlight;
33+
/** @deprecated use html tagged templates and the Snippet component instead */
3034
snippet: typeof helpers.snippet;
35+
/** @deprecated use html tagged templates and the ReverseSnippet component instead */
3136
reverseSnippet: typeof helpers.reverseSnippet;
3237

3338
/**

0 commit comments

Comments
 (0)