Material-ui: CSS.escape polyfill warning when upgrading to beta.17

Created on 14 Nov 2017  路  17Comments  路  Source: mui-org/material-ui

After upgrading from 1.0.0-beta.16 to beta.17, I run the tests and even though they all pass, I get a very large number of warnings like the following:

console.error node_modules/warning/warning.js:51
  Warning: [JSS] CSS.escape polyfill in DEV mode is required in this browser, check out https://github.com/mathiasbynens/CSS.escape

  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

This warning should not appear while running tests.

Current Behavior

The warning message above appears a very large number of times in the console while running all the tests.

Your Environment

| Tech | Version |
|--------------|---------|
| Material-UI | 1.0.0-beta.17 |
| React | 16.0.0 |
| browser | jest |

external dependency

Most helpful comment

yes, just check if you get fresh install of mui that you also get latest react-jss and jss

All 17 comments

browser jest

@gnapse Oh boy. It's coming from https://github.com/cssinjs/jss/pull/625. It's not Material-UI related. cc @kof

I suspected it was not material-ui itself, but I had no idea how to detect where it really came from, that's why I raised the issue here. Thanks!

However, I'm not sure I understand what's the fix. I see that the issue you link from the other project is already merged. So how do I get this fixed in my app then?

@kof I fear everybody is gonna have to install the polyfill for the test environment. Should we reconsider the current tradeoff in the light of this new information?

What if we introduce a "cheap polyfill" using the regex right in the MUI if there is no in the browser?

if there is no in the browser?

@kof Let's take Material-UI test suite as an example. We simulate a browser environment. It's what most people do with enzyme to use the mount() API. I can't see how the detection logic will work.

Detection of CSS.escape is easy. It is if (typeof CSS === 'object' && CSS.escape)

@kof Oh. I have misunderstood what you were saying. So, we would use CSS.escape if available, otherwise we use a cheap cleaning RegExp? This sounds like a great tradeoff 馃挴 .

if (typeof CSS === 'object' && CSS.escape) {
  return
}
if (typeof CSS === 'undefined') window.CSS = {}
CSS.escape = (str) => regexp

If user includes a good polyfill, he will do it before mui loads anyways, so this is just to make sure we don't bother them.

@kof I am having hard time adding a polyfill as it is not being detected and still warning is coming. I am including it like this. I am using your next js example

getContext.js

import 'css-escape'
// ....

It is even coming in the bundle before the warning message console log but no luck still.

@kof anybody is still up on the issue

@pantharshit00 [email protected] has been released and do no longer require the polyfill.

@oliviertassinari is mui automatically getting it? there has been a minor bump in between.

@kof I think it's people concern to reinstall or bump their .lock file.

yes, just check if you get fresh install of mui that you also get latest react-jss and jss

@kof thanks just did yarn upgrade --latest and it fixed the warning

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ryanflorence picture ryanflorence  路  3Comments

activatedgeek picture activatedgeek  路  3Comments

ghost picture ghost  路  3Comments

ghost picture ghost  路  3Comments

iamzhouyi picture iamzhouyi  路  3Comments