-
Notifications
You must be signed in to change notification settings - Fork 65
Description
It appears that the new syncSelectValue – which was changed in this commit – fails to address the case where data-display is used in any of the options. Specifically, the issue occurs here:
nice-select2/src/js/nice-select2.js
Line 442 in e718425
| let option = Array.from(select.options).find(option => option.textContent === item.data.text); |
When data-display is used, t.data.text contains the value specified in data-display but option.textContent does not. So, for example, if you have:
<option value="my-bold-option" data-display="My <strong>bold</strong> option">My bold option</option>then:
t.data.textisMy <strong>bold</strong> option- but
option.textContentisMy bold option
As a result, the variable option stays undefined and an uncaught Javascript error is thrown here:
nice-select2/src/js/nice-select2.js
Lines 448 to 452 in e718425
| if(item.attributes.selected){ | |
| option.selected = true; | |
| } else { | |
| option.selected = false; | |
| } |
interrupting the execution of the importing script.
I tested a solution that takes the data-display case into account and will be happy to contribute with a PR.