Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit fa2406f

Browse files
joekrumphuntabyte
andauthored
fix: escape problematic characters in selector (#103)
Co-authored-by: Hunter Johnston <[email protected]>
1 parent c9e8931 commit fa2406f

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

.changeset/pretty-swans-travel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"cmdk-sv": patch
3+
---
4+
5+
fix: escape problematic characters in selectors

src/lib/cmdk/components/CommandInput.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
2222
const selectedItemId = derived([valueStore, commandEl], ([$value, $commandEl]) => {
2323
if (!isBrowser) return undefined;
24-
const item = $commandEl?.querySelector(`${ITEM_SELECTOR}[${VALUE_ATTR}="${$value}"]`);
24+
const item = $commandEl?.querySelector(
25+
`${ITEM_SELECTOR}[${VALUE_ATTR}="${CSS.escape($value)}"]`
26+
);
2527
return item?.getAttribute('id');
2628
});
2729

0 commit comments

Comments
 (0)