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

Calculations in media query declarations no longer work #3265

Closed
JamesDonnelly opened this issue Jul 5, 2018 · 4 comments
Closed

Calculations in media query declarations no longer work #3265

JamesDonnelly opened this issue Jul 5, 2018 · 4 comments

Comments

@JamesDonnelly
Copy link

JamesDonnelly commented Jul 5, 2018

Today I upgraded a project of mine from LESS 3.0.4 to 3.5.0.

In LESS 3.0.4, the following was perfectly valid:

@media screen and (min-width: (@some-var + 1)) {
  ...
}

However in 3.5.0, the @some-var + 1 part means this entire media query gets excluded from the compiled CSS as if it never existed. No errors are given in the build console (compiling using Webpack and less-loader (neither of which were also updated today)).

I've worked around it for now by performing the calculation on a separate @some-var-plus-one variable:

@some-var-plus-one: @some-var + 1;

@media screen and (min-width: @some-var-plus-one) {
  ...
}

I'm not sure if this is a bug or if this is something intentional.

@JamesDonnelly JamesDonnelly changed the title Calculations in media queries no longer work Calculations in media query declarations no longer work Jul 5, 2018
@matthew-dean
Copy link
Member

matthew-dean commented Jul 5, 2018

However in 3.5.0, the @some-var + 1 part means this entire media query gets excluded from the compiled CSS as if it never existed.

I can't replicate that. What I get is:

// input
@media screen and (min-width: (@some-var + 1)) {
  .selector {
    foo: bar;
  }
}
// output
@media screen and (min-width: (60px + 1)) {
  .selector {
    foo: bar;
  }
}

Like calc() in 3.0, inline expressions are not math'd in media queries in 3.5, which avoids min-aspect-ratio: 16/9 bugs, but yes you can evaluate the calculation in a separate line.

@matthew-dean
Copy link
Member

@JamesDonnelly I've updated the changelog to reflect that this is an intentional change for at-rules to fix other issues regarded inline math for at-rules.

@matthew-dean
Copy link
Member

@JamesDonnelly FYI I've reverted this change in operations for @media, so it'll work as it did before.

@matthew-dean
Copy link
Member

Related to #1880

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