css-vars-ponyfill: does not work in IE11

Hello

I installed your package in my app but in IE11 the css variables are not beeing used

my angular scss file

:root
{
	--primary-color:blue;
}

my component css

...
background-color: var(--primary-color);

it works in chrome,

do I have to do something extra to make it work in IE11 ? include something ?

regards

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 2
  • Comments: 21 (4 by maintainers)

Most upvoted comments

I think the better spot to place the ponyfill is in the polyfills.ts of your angular project. The ponyfill doesn’t have to run in your applications lifecycle, in fact I think it is even better if the css vars ponyfill is set up before angular starts running.

We have an application running this way which works perfectly fine on IE11. Don’t forget other necessary polyfills for IE11 for angular.

Our config:

cssVars({
   onlyLegacy   : true,
   shadowDOM: true,
   watch: true,
   updateURLs: false
 });

@iamdevlinph

The ponyfill has been thoroughly tested and works in IE 11. If you are having issues, consider opening a new issue with either working demo or a more complete configuration copy/pasted here for review.

found the answer here : https://stackblitz.com/edit/css-vars-ponyfill-29?file=src/main.ts

I finaly could make it work like this

cssVars({
  include: 'style',
  onlyLegacy: false,
  watch: true,
  onComplete(cssText, styleNode, cssVariables) {
    console.log(cssText);
  }
});