Skip to content

Commit

Permalink
🐛 fix: broken hints with aplinejs or htmx. Closes #85
Browse files Browse the repository at this point in the history
  • Loading branch information
niketpathak committed Oct 4, 2024
1 parent 8724bf9 commit 7c6968c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/typeahead-standalone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,15 @@ const typeahead = <T extends Dictionary>(config: typeaheadConfig<T>): typeaheadR

// generate markup for hints
const inputHint: HTMLInputElement = input.cloneNode() as HTMLInputElement;

// remove special attributes like those used with alpineJS or htmx from hint element
const specialAttrRegex = /^(x-|hx-|data-|@)/;
for (let i = inputHint.attributes.length - 1; i >= 0; i--) {
if (specialAttrRegex.test(inputHint.attributes[i].name)) {
inputHint.removeAttribute(inputHint.attributes[i].name);
}
}

hint && injectHintEl(inputHint);

listContainer.classList.add(classNames.list, classNames.hide);
Expand Down

0 comments on commit 7c6968c

Please sign in to comment.