Skip to content

Unicode escape sequences in CSS class names are broken during build #1673

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

Closed
adamwathan opened this issue Jun 25, 2018 · 2 comments
Closed

Comments

@adamwathan
Copy link

adamwathan commented Jun 25, 2018

Version

3.0.0-rc.3

Reproduction link

https://github.com/adamwathan/vue-cli-3-css-escape-bug/blob/master/src/App.vue#L19

Steps to reproduce

Create a CSS class in a component's <style> block that includes an escaped digit anywhere but the first character, like:

.foo-\35 0 {
  width: 100px;
  height: 100px;
  background-color: red;
}

Note that \35(space) is the unicode code point for just 5: https://mathiasbynens.be/notes/css-escapes

What is expected?

The resulting CSS is unchanged from what was entered, and using the class foo-50 in your markup applies those styles.

This works fine in Vue CLI 2.* projects: https://codesandbox.io/s/y3koz7zr4z

As well as in regular HTML/CSS: https://jsfiddle.net/4pc1L95n/

What is actually happening?

Somewhere in the build process, the backslash in front of the 3 is being stripped, and you get this resulting CSS instead:

.foo-35 0 {
  width: 100px;
  height: 100px;
  background-color: red;
}

That means foo-50 as a class no longer works properly in the markup.


Of course digits in the middle of CSS classes don't need to be escaped, but we had an issue with Tailwind CSS where folks were escaping the user-supplied portion of classes generated by plugins, and those classes stopped working for people in Vue CLI 3 and Nuxt.js projects when we upgraded our CSS escape function to be spec-compliant:

tailwindlabs/tailwindcss#509

@Akryum Akryum added bug scope: cli-service serve scope: cli-service build needs team repro We acknowledged your report and will soon try to reproduce it labels Jun 28, 2018
@haoqunjiang
Copy link
Member

The Vue CLI 2 version does not work as I run it locally.

Seems like a webpack css-loader bug webpack-contrib/css-loader#578

@haoqunjiang haoqunjiang added upstream and removed needs team repro We acknowledged your report and will soon try to reproduce it labels Jul 11, 2018
@yyx990803
Copy link
Member

If this is a CSS Loader issue I'm afraid there's nothing we can do about it in Vue CLI...

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

4 participants