Repository navigation
Fixes #3147 #2715 - #3213
Fixes #3147 #2715#3213
Conversation
|
I was thinking about this a bit more, and realized that before this is merged, it would need to address this:
It would mean that errors would be thrown at eval time and not parsing time, so the nature of errors would change, but as both are done as a single "pass" from parse to render, it shouldn't matter to the user. (It might mean that, depending on evaluation order and how it might differ from parse order, that 2 errors in a file might switch which fires first, but again, that shouldn't necessarily matter.) Thoughts? |
|
Accidentally pressed the "close" button. |
Btw., indeed, the example at #3147 is questionable for this part also: @function-name: regexp;
@-moz-document @{function-name} ...Nothing in documentation suggests In general, this:
brings us to "Less variables are not text-replacement-macros" discussion at #3059. Aside of above I guess my only concern about the PR would be the following kind of code: @-moz-whatever (foo: "(" @boom-boom ")") {
// ...
}Will it work? |
|
Just tested. The output of : is the same: That's the expected output, yes? Or do you mean it should be a regular var substitution? |
|
Re: this
I think I see what you mean. That would be a breaking change, correct? Let me think on this. |
- Allow variables to fallback to permissive parsing
|
TL;DR - I allowed variables to "fallback" to permissive parsing, to allow them to be inserted wherever. But it also allows a few other neat possibilities and would close other bugs, but it would also probably need a major Less version bump. I also fixed it so it wasn't forcing / breaking at-rules and custom properties to use @seven-phases-max With the latest commit, this input: @function-name: regexp;
@d-value: 15;
@-moz-document @function-name("(\d{0,@{d-value}})") {
a {
color: red;
}
}
.custom-property {
--this: () => {
basically anything until final semi-colon;
even other stuff; // i\'m serious;
};
@this: () => {
basically anything until final semi-colon;
even other stuff; // i\'m serious;
};
--that: @this;
@red: lighten(red, 10%);
--custom-color: @red;
custom-color: $--custom-color;
}
@iostat: 1;
.var {
--fortran: read (*, *, iostat=@iostat) radius, height;
}
@boom-boom: bam;
@-moz-whatever (foo: "(" @boom-boom ")") {
bar: foo;
}
@selectorList: #selector, .bar, foo[attr="blah"];
@{selectorList} {
bar: value;
}
@size: 640px;
@tablet: (min-width: @size);
@media @tablet {
.holy-crap {
this: works;
}
}Produces this output: @-moz-document regexp("(\d{0,15})") {
a {
color: red;
}
}
.custom-property {
--this: () => {
basically anything until final semi-colon;
even other stuff; // i'm serious;
};
--that: () => {
basically anything until final semi-colon;
even other stuff; // i'm serious;
};
--custom-color: #ff3333;
custom-color: #ff3333;
}
.var {
--fortran: read (*, *, iostat=1) radius, height;
}
@-moz-whatever (foo: "(" bam ")") {
bar: foo;
}
#selector, .bar, foo[attr="blah"] {
bar: value;
}
@media (min-width: 640px) {
.holy-crap {
this: works;
}
} |
|
See my comment here. It looks like what I'm treating as valid in this PR pretty closely matches what Chrome considers valid, with the exception that I'm removing escapes, which I probably shouldn't, according to Chrome behavior. |
|
So I can't see anything wrong with it now. It should do the trick I guess. Well, I suspect one still can break it with some |
I may try to make the Speaking of, when I'm ready to merge, and later release, what are your thoughts on version |
|
Bumping it to |
|
@seven-phases-max Yeah, I was thinking a jump to 3.5 would be good. K. I'll look at the selectors branch as well. That might fit well together with this once merged. Can you look at #3223? Thanks for your help reviewing lately! |
|
|
|
@seven-phases-max Never mind, figured it out. See: #3228 |
{and;there) #3147 Less fails to parse valid Custom Property values (ex: @apply polyfill) #2715Custom property values and unknown at-rule entities are essentially treated as literals that replace variable references, meaning you can write:
The only rule with permissive parsing is that you have matching
{}()[]"', and I've added error tests for those. Each block ignores anything except its closing block, and only the top-most block is looking for a final parsing token(s).