bluzky / nice-select2

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

null value in classList #71

Open Csaba27 opened 11 months ago

Csaba27 commented 11 months ago

Line 241 to 245

because of this, pushing null value to classList

var classList = [
  "option",
  option.attributes.selected ? "selected" : null,
  option.attributes.disabled ? "disabled" : null,
];

Fixes

var classList = ["option"];

if (option.attributes.selected) classList.push("selected")
if (option.attributes.disabled) classList.push("disabled")
Csaba27 commented 11 months ago

Unnecessary spaces in the classes list

Line 177

NiceSelect.prototype.renderDropdown = function() {
  var classes = [
    "nice-select",
    attr(this.el, "class") || "",
    this.disabled ? "disabled" : "",
    this.multiple ? "has-multiple" : ""
  ];

ex. ['nice-select', 'element-classlist', '', '']

Fixes

var classes = ["nice-select"];

if (attr(this.el, "class")) classes.push(attr(this.el, "class"))
if (this.disabled) classes.push("disabled")
if (this.multiple) classes.push("has-multiple")