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

Variable properties $@ not working within if() #3451

Closed
sabl0r opened this issue Nov 13, 2019 · 3 comments
Closed

Variable properties $@ not working within if() #3451

sabl0r opened this issue Nov 13, 2019 · 3 comments

Comments

@sabl0r
Copy link

sabl0r commented Nov 13, 2019

Variable properties are working in general but not if you use them within if() (maybe other functions as well).

The code below gives me this for the "nok" mixin:

property "100" not found

I know that this feature is not yet documented (less/less-docs#500), but is this usecase supposed to work or not?

@devices: {
	mobile: 420;
	tablet: 800;
	desktop: 1024;
	widescreen: 1280;
	fullhd: 1440;
}


.nok(@d) {
	@w: if(iskeyword(@d), @devices[$@d], @d);
	width: @w;
}

.ok(@d) {
	@w: if(iskeyword(@d), @d, @d);
	width: @w;
}

.ok {
	.ok(tablet);
	.ok(100px);
}

.nok {
	.nok(tablet);
	.nok(100px);
}
@matthew-dean
Copy link
Member

This is actually a duplicate of #3371

The issue is that all Less functions evaluate all arguments, so you can't optionally evaluate based on the first statement of the function. Therefore the else statement immediately fails. This is a planned feature in the future.

@matthew-dean
Copy link
Member

Closing as duplicate.

@sabl0r
Copy link
Author

sabl0r commented Nov 14, 2019

Thanks for the fast feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants