Mobius1 / Selectr

A lightweight, vanilla javascript select box replacement. No dependencies.
MIT License
313 stars 77 forks source link

width option not working #103

Open 1grafik opened 5 years ago

1grafik commented 5 years ago

I don't know much about English, so I'm sorry.

build() method that changes the width of the code does not work.

Fix: Replace : if (isset(this.config, "width"))

To: if (typeof this.config.width !== 'undefined')

coolibry commented 5 years ago

thanks for that, it's work for me (and before not).

davidjkrause commented 5 years ago

Yes, thanks so much for this suggested change. Without it, width option doesn't apply for me when used like:

var newSelectr = new Selectr('#some-id', { searchable: false, width: 190 });

NitemareReal commented 5 years ago

The problem is still there in production version (minified). If you use: width: 190 then, "isset" call from line 331 (patched by @1grafik as a solution ) returns false because condition (obj[prop] === true || obj[prop].length) is evaluated as false since first part is false and second part is undefined If you use: width: "190" "isset" call from line 331 returns true but "util.isInt" call returns false since first condition: typeof val === 'number' is false (obviosly)