lcdsantos / jQuery-Selectric

jQuery plugin for easy manipulation and customization of HTML selects
http://selectric.js.org/
MIT License
727 stars 157 forks source link

Namespace all selectors and styles using BEM conventions #170

Open SethTompkins opened 7 years ago

SethTompkins commented 7 years ago

I have been using your awesome library recently and have run into some issues with how the selectors architected. Classes like .button can cause a mess when you also have a standard .button component in your style sheet.

I propose to namespace all selectors for this library appropriately using BEM conventions. The root element should be .selectric and all other elements as .selectric__element-name. This would also require changes to the stylesheet.

Would you be interested in this contribution? I would be happy to take the time to put together a PR if it would be considered.

lcdsantos commented 7 years ago

Yes! I'm really interested in that.

I haven't done this myself yet because I don't have time at the moment.

We have to be a little careful though, since there's legacy options to switch classes cases. Take a look at jquery.selectric.js for example. I don't know what the behaviour would be in this case. Maybe remove this functionality all together?

SethTompkins commented 7 years ago

Yea, this would be a backwards-incompatible change, requiring a major version # bump.

It looks like most of the selectors are covered using the prefix option, however even if you use that option .button, .label, .selected, and .last are hardcoded classnames that float in the global namespace.

I would recommend removing that functionality, I don't think it is integral to this lib.

jeffreyscottfrench commented 7 years ago

All for this. I'm about to implement this on a project - are these revisions underway? Odds of being completed in a few days? If not no big deal, just would like to not do it twice because I missed it by a day or two ha!

SethTompkins commented 7 years ago

I have not started on this, I was waiting to hear back on whether breaking backwards compat was a no no...

jeffreyscottfrench commented 7 years ago

Ah ok - thanks for the info!

lcdsantos commented 7 years ago

We ship it on v2.

It's ok to not be backwards compatible.