Skip to content
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

Extra semicolon output #2959

Closed
googabeast opened this issue Sep 6, 2016 · 2 comments
Closed

Extra semicolon output #2959

googabeast opened this issue Sep 6, 2016 · 2 comments

Comments

@googabeast
Copy link

googabeast commented Sep 6, 2016

Other compilers cannot handle the complexity of this so I was unable to isolate this down to the app, or the LESS language it's self. CodeKit is amazing btw!

Quick overview:
There is a extra semicolon rendering as the last character output of a advanced mixin() that uses JavaScript, arrays, and for loops.

It still renders browser readable CSS, just doesn't pass validation and is another minor glitch I am attempting to overcome.

Also a posting on stackoverflow for the issue, just to see if others have encountered anything like this in the LESS language its self.
http://stackoverflow.com/questions/39338429/less-outputs-extra-semicolon

From another stack overflow developer a codePen that shows the same output.
http://codepen.io/anon/pen/NRPrqx?editors=0100#0

Expected result:
Not to include the extra semicolon at the end of the string.

Current output:
@media only screen and (max-width: 1025px) { -lessMinded: "tablet"; body{ padding:30px } nav{ margin:10px } ul{ margin:10px } li{ margin:10px } p{ margin:10px } a{ margin:10px }; }

Repo:
Add any new CSS property to any one of the testing tags within "/styles.less", when compiled you will see the above output within the media query.

Supplied files:
_less.zip

LessMinded.less
LINES 15 & 20 are the mixins() themselves being called.

LessMindedFunc.less
LINES 4 & 10 are the JavaScript functions being requested by the mixins(). Function api.media() is the function that ends up outputting the additional semicolon. You can adjust the .substring() function on LINE 17 and regardless of the count it still returns the extra semicolon.

Please let me know if I happen to be missing anything.

@seven-phases-max
Copy link
Member

seven-phases-max commented Sep 20, 2016

The final ; is expected since Less just can't know that your JS function returns a "string of ruleset(s)" instead of an expected single property value (and then for Less it's still a property value and not an "abstract CSS text", hence the property: whatever-your-function-returns; output with the semicolon).

So I see no issue here, it's expected behaviour (it's just the way you use the inline JS stuff is nothing but a hack-at-your-own-risk). Just one remark: since inline JS is actually highly anticipated, think twice before implementing a library of your helper functions this way (look at #1648 for why it's actually harmful). Instead consider writing a plugin instead (see the corresponding docs and an alt. #2522 plugin format which is probably more suitable for your needs).

@stale
Copy link

stale bot commented Nov 14, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 14, 2017
@stale stale bot closed this as completed Nov 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants