Skip to content

Commit 47ff921

Browse files
committed
refactor(RangeSlider): improve the name option handling
1 parent 4d9c1b5 commit 47ff921

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

js/src/range-slider.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,12 @@ class RangeSlider extends BaseComponent {
241241
inputElement.max = this._config.max
242242
inputElement.step = this._config.step
243243
inputElement.value = value
244-
inputElement.name = Array.isArray(this._config.name) ?
245-
`${this._config.name[index]}` :
246-
`${this._config.name || ''}-${index}`
244+
if (this._config.name) {
245+
inputElement.name = Array.isArray(this._config.name) ?
246+
`${this._config.name[index]}` :
247+
`${this._config.name}-${index}`
248+
}
249+
247250
inputElement.disabled = this._config.disabled
248251

249252
// Accessibility attributes
@@ -584,7 +587,7 @@ class RangeSlider extends BaseComponent {
584587
config.labels = config.labels.split(/,\s*/)
585588
}
586589

587-
if (typeof config.name === 'string') {
590+
if (typeof config.name === 'string' && config.name.includes(',')) {
588591
config.name = config.name.split(/,\s*/)
589592
}
590593

0 commit comments

Comments
 (0)