-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add arguments-list which is comma seperated #941
Conversation
Fixes #228, which had a similar suggestion to fix. |
following suggestion from @cloudhead in #939... I originally liked args but arguments-list is, although more verbose, clearer in what it delivers.. In terms of the alternative (a function that converts space seperated to comma seperated) the only use for it I can see if with the ...@rest syntax for getting a list of the remaining arguments.. if that became a feature request like this, what would we do? Auto create a variable @rest-list or add a function and depreciate arguments-list? or would we reject a request along those lines? |
A function for converting the delimiter has a lot more utility. The best example you mentioned, I hope this patch does not make it in. It's a hack to get around one specific use case of arguments. |
@agatronic yeah I was just linking the PR to the issue it solves. Not trying to change the keyword. I had the same thought about @leafo I agree that a utility function to convert something like |
Here's my main problem with this: it actually reinforces a design flaw in LESS, rather than solve the actual problem. What's the problem: that people aren't actually intending to send multiple arguments to the mixin, and are, in fact, really intending to send a single argument. It's just that that single argument is a legal CSS value that contains a comma. Here, I'll prove it: .mymixin(@boxShadow, @color) {
box-shadow: @boxShadow;
color: @color;
} Box shadow is a single argument, but that argument may contain commas. It's that simple, and the problem has been in LESS for a long time. (See Issue #35). String escaping is a hack to solve it. JavaScript regex is a hack. And now @arguments-list is a hack. But none of them address the core problem, which is the design oversight of mixin arguments that contain commas (and this most recent hack won't actually fix the issue, such as in the example above). I think if we put this in, we risk muddying the realm of best practice for LESS, because it's another hack and we haven't quite addressed what to do about commas in mixins. If you look at issue #35, there's a discussion about what to do about the problem. There's a few suggestions on the table: replacing commas with semi-colons for mixins, and allowing optional "wrapping" of arguments with parentheses (as SASS does). I recommend we solve this core issue ASAP, which will effectively wipe the need for these other hacks and temporary shims and new keywords off the table, along with further alleviating the need for JavaScript inside LESS. |
I see your point... I like brackets around all the arguments.. I don't like ; for argument delimitting Can we agree a best approach ASAP and I'll close this and implement what we decide. |
See revised comment on #35 where @MatthewDL makes some more good points. |
Ideally we would do semicolons for argument delimiter, but it's too late to change that now. I'm in favor of adding the ability to wrap a list in parentheses. Edit: I also still think we need functions to manipulate lists, especially if we are making lists first class types. |
@MatthewDL we have semi-colons as seperators.. you mentioned at once point we could always take both solutions.. do you want this pull request in or shall we close it? I don't particularly mind either way. |
I say don't put @arguments-list in. While it may, on the surface, seem similar to @arguments, the use case is completely different. With @arguments, I'm probably defining many parts of a shorthand CSS, and then concatenating them in a final value. With @arguments-list, you're not defining many values, it's really only one value that is (was) getting misinterpreted by LESS as a separate value, so then you were reassembling the original value, essentially replacing the comma that was inaccurately removed. It's a hack for a design flaw. Semi-colons in your argument list solves that exact same use case, but in a more accurate and elegant way that's easier to understand. |
To avoid the popular javascript hacks to convert @arguments into a comma seperated list