Selectr icon indicating copy to clipboard operation
Selectr copied to clipboard

Plugin started while including (with missing DOM arg), before call

Open artem-tkachuck opened this issue 8 years ago • 4 comments
trafficstars

Reproducing Steps:

  1. npm install mobius1-selectr --save
  2. require("mobius1-selectr")

(!) Here I got next one:

selectr.js:922 Uncaught Error: You must supply either a HTMLSelectElement or a CSS3 selector string. at Object.m (selectr.js:922) at s.defaultSelected (selectr.js:11) at Object. (selectr.js:15) at t (bootstrap aaae86e04d25fb32a59e:19) at Object. (_components.js:27) at t (bootstrap aaae86e04d25fb32a59e:19) at Object. (index.js:5) at t (bootstrap aaae86e04d25fb32a59e:19) at bootstrap aaae86e04d25fb32a59e:62 at bootstrap aaae86e04d25fb32a59e:62

  1. new Selectr(document.getElementById('taggable'));

If I understood right - plugin run on step#2 (require ...), not step#3 (new Selectr...), but why? Explain or Fix, please.. thx.

artem-tkachuck avatar Sep 03 '17 14:09 artem-tkachuck

Wow, i searched for hours because of this, and it was on here all along.

Yeah the method for calling this library doesn't seem ordinary

MrBrax avatar Sep 26 '17 10:09 MrBrax

This is progress to be rectified in the next major version.

Mobius1 avatar Sep 26 '17 12:09 Mobius1

Found a solution yesterday, can be overridden with:

const Selectr = require("imports-loader?this=>window,define=>false!mobius1-selectr/src/selectr.js");

Needs imports-loader.

MrBrax avatar Sep 27 '17 07:09 MrBrax

I've not has much free time to look at this, but if anyone wants to submit a pull request with a fix, I'll be happy to merge it.

Mobius1 avatar Oct 16 '17 16:10 Mobius1