mirror of
https://github.com/Choices-js/Choices.git
synced 2024-06-08 00:42:15 +02:00
Merge pull request #990 from Choices-js/fix-search-sanitisation
Remove character sanitisation when searching
This commit is contained in:
commit
781c729e13
|
@ -1734,6 +1734,38 @@ describe('choices', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('events', () => {
|
||||
describe('search', () => {
|
||||
beforeEach(() => {
|
||||
document.body.innerHTML = `
|
||||
<select data-choice multiple></select>
|
||||
`;
|
||||
|
||||
instance = new Choices('[data-choice]', {
|
||||
allowHTML: false,
|
||||
searchEnabled: true,
|
||||
});
|
||||
});
|
||||
|
||||
it('details are passed', (done) => {
|
||||
const query =
|
||||
'This is a <search> query & a "test" with characters that should not be sanitised.';
|
||||
|
||||
instance.input.value = query;
|
||||
instance.input.focus();
|
||||
instance.passedElement.element.addEventListener('search', (event) => {
|
||||
expect(event.detail).to.eql({
|
||||
value: query,
|
||||
resultCount: 0,
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
instance._onKeyUp({ target: null, keyCode: null });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('private methods', () => {
|
||||
describe('_createGroupsFragment', () => {
|
||||
let _createChoicesFragmentStub;
|
||||
|
|
|
@ -1513,7 +1513,7 @@ class Choices implements Choices {
|
|||
this._isSearching = false;
|
||||
this._store.dispatch(activateChoices(true));
|
||||
} else if (canSearch) {
|
||||
this._handleSearch(this.input.value);
|
||||
this._handleSearch(this.input.rawValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,10 @@ export default class Input {
|
|||
this.element.value = value;
|
||||
}
|
||||
|
||||
get rawValue(): string {
|
||||
return this.element.value;
|
||||
}
|
||||
|
||||
addEventListeners(): void {
|
||||
this.element.addEventListener('paste', this._onPaste);
|
||||
this.element.addEventListener('input', this._onInput, {
|
||||
|
|
Loading…
Reference in a new issue