Skip to content

Commit

Permalink
Escape querySelector option value
Browse files Browse the repository at this point in the history
This to correctly find values like "["test"]".
  • Loading branch information
Bartheyrman22 authored Mar 3, 2025
1 parent 314ca71 commit 6b802fc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Autocomplete/assets/src/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export default class extends Controller {
for (const [, tomSelectOption] of Object.entries(this.tomSelect.options)) {
if (tomSelectOption.$order === optionOrder) {
orderedOption = parentElement.querySelector(
`:scope > option[value="${tomSelectOption[this.tomSelect.settings.valueField]}"]`
`:scope > option[value="${tomSelectOption[this.tomSelect.settings.valueField].replace(/["\\]/g, '\\$&')}"]`
);

break;
Expand Down

0 comments on commit 6b802fc

Please sign in to comment.