Skip to content

Commit

Permalink
feat(js): add non-input container invariant
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour committed Dec 7, 2020
1 parent 0e28f55 commit 2e3a8ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/autocomplete-core/src/checkOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { warn } from '@algolia/autocomplete-shared';
import { AutocompleteOptions, BaseItem } from './types';

export function checkOptions<TItem extends BaseItem>(
option: AutocompleteOptions<TItem>
options: AutocompleteOptions<TItem>
) {
warn(
!option.debug,
!options.debug,
'The `debug` option is meant for development debugging and should not be used in production.'
);
}
6 changes: 5 additions & 1 deletion packages/autocomplete-js/src/autocomplete.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BaseItem, createAutocomplete } from '@algolia/autocomplete-core';
import { createRef } from '@algolia/autocomplete-shared';
import { createRef, invariant } from '@algolia/autocomplete-shared';

import { createAutocompleteDom } from './createAutocompleteDom';
import { createEffectWrapper } from './createEffectWrapper';
Expand Down Expand Up @@ -204,6 +204,10 @@ export function autocomplete<TItem extends BaseItem>({

runEffect(() => {
const containerElement = getHTMLElement(container);
invariant(
containerElement.tagName !== 'INPUT',
'The `container` option does not support `input` elements. You need to change the container to a `div`.'
);
containerElement.appendChild(root);

return () => {
Expand Down

0 comments on commit 2e3a8ed

Please sign in to comment.