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

null string for compiling #2831

Open
kbdsbx opened this issue Mar 4, 2016 · 2 comments
Open

null string for compiling #2831

kbdsbx opened this issue Mar 4, 2016 · 2 comments

Comments

@kbdsbx
Copy link

kbdsbx commented Mar 4, 2016

/* making .display-block */
.make-classes () {
    @item : ~"";
    .make-classes( @item );
}

/* making .xs-display-block */
.make-classes ( @class ) when ( iskeyword( @class ) ) {
    @item : ~"@{class}-";
    .make-classes( @item );
}

/* inner function */
.make-classes ( @class ) when ( isstring( @class ) ) {
    .@{class}display-block { display: block; }
}

.make-classes ();

.make-classes( xs );

If I want to taking .display-block into some class as :

.shi {
    .display-block;
}

it will be tell me

NameError: .display-block is undefined on line 21, column 5:

but if I using .xs-display-block

.shi {
    .xs-display-block;
}

It's works.

so... Is that the null string are not supporting when compiling?

@SomMeri
Copy link
Member

SomMeri commented Mar 4, 2016

Interpolated rulesets (e.g. .@{class}display-block) should not work as mixins (see #1196 and #1338 for related issue).

Theoretically, neither .xs-display-block nor .display-block call should be working. But, it is interesting that this works too.

@seven-phases-max
Copy link
Member

seven-phases-max commented Mar 25, 2016

Theoretically, neither .xs-display-block nor .display-block call should be working.

They should per #1624 (so this is basically a bug in #1624).


Regardless of the error one should avoid such code (to be honest by these days I suppose that was a mistake to implement this feature at all). If one needs a parametric mixin she just uses parametric mixin (note in .shi both void and xs are nothing but parameters for a whatever mixin with one parameter) ``. Ideally (for manageable and solid code) parametric mixins must never be emulated via CSS classes (despite Less partially allowing you to do so via combination of certain features, i.e. "selector interpolation" + "interpolated-classes-as-mixin"). For more details and examples see #2702.

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

3 participants