seiyria / bootstrap-slider

A slider control for Bootstrap 3 & 4.
http://seiyria.github.io/bootstrap-slider/
Other
2.99k stars 1.14k forks source link

Quotes vs double quotes in data-slider-ticks-labels #645

Open barseghyanartur opened 7 years ago

barseghyanartur commented 7 years ago

It's very simple.

When data-slider-ticks-labels are given as follows, it works:

data-slider-ticks-labels='["short", "medium", "long"]'

And this does NOT work (no labels are shown):

data-slider-ticks-labels="['short', 'medium', 'long']"

See JSFiddle.

So, when single quotes are used, it doesn't work.

The following also not (no labels):

data-slider-ticks-labels="[\"short\", \"medium\", \"long\"]"
seiyria commented 7 years ago

It's possible that it's because it does JSON parsing.

As such, there's not anything we can do to fix this (besides do some things that I don't think we should do). If you want different control, please do it via JS instead of HTML.

barseghyanartur commented 7 years ago

@seiyria:

Let me disagree with you. Most of the freameworks use double quotes for HTML attributes:

data-slider-ticks-labels="['short', 'medium', 'long']"

Fix is trivial. I can submit a pull request. Let me know, please.

seiyria commented 7 years ago

I'm interested in your fix (mostly curiosity), but I still disagree with the premise.

barseghyanartur commented 7 years ago

Don't you agree, that making a product more developer-friendly is making a better product?

seiyria commented 7 years ago

I believe there's a middleground that is a tradeoff in developer-friendliness and maintainability, which comes from simple solutions to problems and good documentation (which I believe we have achieved with the current implementation + documentation). I'm not willing to debate my philosophy further on a random thread on github, because it never really goes well.

barseghyanartur commented 7 years ago

Single quotes are uncommon. Bootstrap3 itself uses double quotes. Foundation5 uses double quotes. The right choice is obvious.

FYI:

Use double ("") rather than single quotation marks ('') around attribute values.

Double quotes around attribute values are the most common in HTML, but single quotes can also be used.


Nice project, though. MIT = do what you want. Thanks for that.

rovolution commented 7 years ago

@barseghyanartur feel free to make a PR! We would definitely appreciate it

rovolution commented 7 years ago

@seiyria he cited some pretty credible sources to validate his point, so I think we should definitely be willing to accept a PR for this

seiyria commented 7 years ago

@rovolution I said I'd be interested in looking at his fix (all of the ones I have in mind, I also have loopholes in mind for why they're bad), but instead he chose to bikeshed at me in the way that he did, which doesn't really sit well with me.

That aside, I don't find w3schools to be particularly credible (it has been getting better) and google has always been a proponent of doing their own thing (dart, traceur, closure, etc) so of course they have opinions.

Personally, I prefer double quotes for attributes too. However, given that I have no idea what his proposed solution is (which I did say I was interested in), I am still siding with what I said above.

rovolution commented 7 years ago

understood. I just saw the part where he offered to make a PR, and as long as it adheres to our guidelines, I'm cool.

reggieriser commented 7 years ago

Just ran into this issue as well. Part of my confusion came from the fact that I was referencing Example 14 from the API examples page, which shows the (non-working) double quotes with embedded single quotes. That should probably be changed until this is fixed.

BTW, I'm using a framework (Django) to output these custom attributes on a text widget. Django renders attribute values in double quotes, so it's not trivial for me to just flip the double-quotes to single quotes.

barseghyanartur commented 7 years ago

@reggieriser:

A workaround example.

rovolution commented 7 years ago

That should probably be changed until this is fixed.

I will go ahead and update the example to reflect the correct version until there is a fix for this. thanks!

mayankvara commented 4 years ago

when does it get marged i am also facing issue with quote.