bluzky / nice-select2

A lightweight vanilla javascript library that replaces native select elements with customizable dropdowns
https://bluzky.github.io/nice-select2/
MIT License
370 stars 61 forks source link

extractData when page is reloaded #25

Closed lhapaipai closed 1 year ago

lhapaipai commented 2 years ago

Hi ! Thanks for your nice select ! I can suggest you to use the javascript properties instead of html attributes in your extractData method. If you refresh your page and you have selected some options in your select form. your options are not coded in the html attributes but are clearly visible to the user and accessible with javascript.

file : src/js/nice-select2.js#L119

    var attributes = {
-      selected: item.getAttribute("selected") != null,
+      selected: item.selected,
-      disabled: item.getAttribute("disabled") != null,
+      disabled: item.disabled,
       optgroup: item.tagName == 'OPTGROUP'
    };
Tsjippy commented 1 year ago

fixed