Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: add throw error if element not found #379

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dist/autoComplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@
resultsList.id = resultsList.id || name + "_list_" + ctx.id;
resultItem.id = resultItem.id || name + "_result";
ctx.input = select$1(ctx.selector);
if (!(ctx.input instanceof HTMLElement)) throw new Error("DOM Element selector not found. Check that your selector is valid and element exist.");
});

var eventEmitter = (function (name, ctx) {
Expand Down
Binary file modified dist/autoComplete.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion dist/autoComplete.min.js

Large diffs are not rendered by default.

Binary file modified dist/autoComplete.min.js.gz
Binary file not shown.
1 change: 1 addition & 0 deletions docs/demo/js/autoComplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@
resultsList.id = resultsList.id || name + "_list_" + ctx.id;
resultItem.id = resultItem.id || name + "_result";
ctx.input = select$1(ctx.selector);
if (!(ctx.input instanceof HTMLElement)) throw new Error("DOM Element selector not found. Check that your selector is valid and element exist.");
});

var eventEmitter = (function (name, ctx) {
Expand Down
Binary file modified docs/demo/js/autoComplete.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/demo/js/autoComplete.min.js

Large diffs are not rendered by default.

Binary file modified docs/demo/js/autoComplete.min.js.gz
Binary file not shown.
49 changes: 48 additions & 1 deletion docs/how-to-guides.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,31 @@ filter: (list) => {

<!-- panels:end -->

## `Show all items on click`

<!-- panels:start -->
<!-- div:left-panel -->

##### Code:

```js
// autoComplete.js Config Options
threshold: 0,
resultsList: {
maxResults: undefined
},
```

<!-- div:right-panel -->

##### Example

<input type="text" dir="ltr" spellcheck=false autocorrect="off" autocomplete="off" autocapitalize="off" id="autoComplete_07">

<!-- panels:end -->

***

<script>
const data = {
src: ["Pizza", "Burgers", "Sushi", "Coffee", "Soda", "Fresh Juice"]
Expand Down Expand Up @@ -442,4 +467,26 @@ filter: (list) => {
}
}
});
</script>

const autoCompleteJS_07 = new autoComplete({
selector: "#autoComplete_07",
placeHolder,
data,
threshold: 0,
resultsList: {
maxResults: undefined
},
resultItem,
events: {
input: {
focus (event) {
autoCompleteJS_07.start();
},
selection (event) {
const selection = event.detail.selection.value;
autoCompleteJS_07.input.value = selection;
}
},
},
});
</script>
1 change: 1 addition & 0 deletions src/services/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ export default (ctx) => {

// Assign the "input" html element
ctx.input = select(ctx.selector);
if (!(ctx.input instanceof HTMLElement)) throw new Error("DOM Element selector not found. Check that your selector is valid and element exist.");
};