Skip to content

Commit 3296895

Browse files
committed
fix: address coderabbit safety suggestions (use escapejs)
1 parent 8dfffe7 commit 3296895

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

templates/v3/includes/_field_combo.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
jsReady: false,
2222
open: false,
2323
query: '',
24-
selected: '{{ selected|default:'' }}',
24+
selected: '{{ selected|default:''|escapejs }}',
2525
selectedLabel: '',
2626
options: [],
2727
activeIndex: -1,
@@ -35,7 +35,7 @@
3535
this.jsReady = true;
3636
this.options = JSON.parse(document.getElementById('field-{{ name }}-options').textContent);
3737
if (this.selected) {
38-
const match = this.options.find(o => o.value === this.selected);
38+
const match = this.options.find(o => String(o.value) === String(this.selected));
3939
if (match) this.selectedLabel = match.label;
4040
}
4141
},
@@ -130,9 +130,9 @@
130130
<template x-for="option in filtered" :key="option.value">
131131
<div class="dropdown__item"
132132
:id="'field-{{ name }}-option-' + option.value"
133-
:class="{ 'dropdown__item--selected': selected === option.value, 'dropdown__item--active': activeValue === option.value }"
133+
:class="{ 'dropdown__item--selected': String(selected) === String(option.value), 'dropdown__item--active': activeValue === option.value }"
134134
role="option"
135-
:aria-selected="selected === option.value"
135+
:aria-selected="String(selected) === String(option.value)"
136136
@click="choose(option.value, option.label)"
137137
@keydown.enter.prevent="choose(option.value, option.label)"
138138
@keydown.space.prevent="choose(option.value, option.label)"

0 commit comments

Comments
 (0)