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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS calc() breaks when using 3+ variable fallbacks on Ivy/Angular 9 #16910

Closed
1 of 15 tasks
yutamago opened this issue Feb 10, 2020 · 3 comments 路 Fixed by #17891
Closed
1 of 15 tasks

CSS calc() breaks when using 3+ variable fallbacks on Ivy/Angular 9 #16910

yutamago opened this issue Feb 10, 2020 · 3 comments 路 Fixed by #17891
Labels
area: devkit/build-angular freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix
Milestone

Comments

@yutamago
Copy link

yutamago commented Feb 10, 2020

馃悶 Bug report

Command

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • xi18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Yes, the previous version in which this bug was not present was: 8.2.3

Description

var(--x, var(--y, var(--z, 0))) breaks inside of the calc-function.
Whereas var(--x, var(--y, 0)) still seems to work.

馃敩 Minimal Reproduction

  1. Put following class selector in any component stylesheet.
.some-rule-lg {
  --width-lg: 1px;
  --width-md: 2px;
  --width-sm: 3px;
  --offset-lg: 4px;
  --offset-md: 5px;
  --offset-sm: 6px;
  width: calc(var(--width-lg, var(--width-md, var(--width-sm, 0))) + var(--offset-lg, var(--offset-md, var(--offset-sm, 0))));
}
  1. Build using ng build --aot --prod

馃敟 Exception or Error

ERROR in Parse error on line 1: 
var(--width-lg, var(--width-md, var(--width-sm, 0))) + var(--...
---------------------------------------------------^
Expecting end of input, "ADD", "SUB", "MUL", "DIV", got unexpected "RPAREN"

馃實 Your Environment


Angular CLI: 9.0.1
Node: 10.15.3
OS: win32 x64

Angular: 9.0.0
... animations, cdk, common, compiler, compiler-cli, core, forms
... language-service, material, material-moment-adapter
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.1
@angular-devkit/build-angular     0.900.1
@angular-devkit/build-optimizer   0.900.1
@angular-devkit/build-webpack     0.900.1
@angular-devkit/core              9.0.1
@angular-devkit/schematics        9.0.1
@angular/cli                      9.0.1
@ngtools/webpack                  9.0.1
@schematics/angular               9.0.1
@schematics/update                0.900.1
rxjs                              6.5.4
typescript                        3.7.5
webpack                           4.41.2

Anything else relevant?
We're using SCSS for our stylesheets.

@yutamago
Copy link
Author

yutamago commented Feb 10, 2020

Found a workaround: Put the operands of the calculation into their own variables before using calc()

Instead of

.some-rule-lg {
  --width-lg: 1px;
  --width-md: 2px;
  --width-sm: 3px;
  --offset-lg: 4px;
  --offset-md: 5px;
  --offset-sm: 6px;
  width: calc(var(--width-lg, var(--width-md, var(--width-sm, 0))) + var(--offset-lg, var(--offset-md, var(--offset-sm, 0))));
}

do this

.some-rule-lg {
  --width-lg: 1px;
  --width-md: 2px;
  --width-sm: 3px;
  --offset-lg: 4px;
  --offset-md: 5px;
  --offset-sm: 6px;

  --temp-calc1: var(--width-lg, var(--width-md, var(--width-sm, 0)));
  --temp-calc2: var(--offset-lg, var(--offset-md, var(--offset-sm, 0)));
  width: calc(var(--temp-calc1) + var(--temp-calc2));
}

@dgp1130
Copy link
Collaborator

dgp1130 commented Feb 20, 2020

Looks like a in the CSS optimizer we use (CSSNano). I'm able to reproduce it on their playground (error is in the JavaScript console).

Filed an issue for them to look at: cssnano/cssnano#880. Once it gets fixed there, Angular should receive the fix in our natural rollout process. There's nothing for us to do here, just in a holding pattern until it gets addressed upstream.

filipesilva pushed a commit that referenced this issue Jun 10, 2020
Disable `calc` optimizations due to several issues.

Closes #16910 closes #16875 and closes #17890
filipesilva pushed a commit that referenced this issue Jun 10, 2020
Disable `calc` optimizations due to several issues.

Closes #16910 closes #16875 and closes #17890
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jul 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: devkit/build-angular freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants