-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Broken unicode symbol after minification #6521
Comments
Using what minifier? |
As @mgechev says "The combination of ng2-inline-templates & typescript breaks the CSS.". |
Check our discussion here mgechev/angular-seed#390 |
@tandu Have you tried using two backslashes? It's in a string, so you need to escape the backslash to use it. Edit: To be clear, I don't know Angular. Just going off the inline template comment (mgechev/angular-seed#390 (comment)) which is using a string, hence the backslash needs to be escaped. |
In that case css for angular2-seed in dev mode works incorrectly. I.e. dev and prod modes handle this css rule differently. |
Here is zipped application that introduces the issue https://github.com/mgechev/angular2-seed/files/92926/angular2-seed.zip |
@tandu I can't comment on Angular-specifics, but if this is inside a JavaScript string, it needs two backslashes to be in the output. The fact that it sounds like it works in dev is the bug to me. |
In dev css is not minified I think this is the difference. In css unicode symbol should be defined using one slash, check here, for example: http://stackoverflow.com/questions/10393462/placing-unicode-character-in-css-content-value so it looks like a bug that minifier requires 2 backslashes. |
@tandu No, it's not. You're writing JavaScript, not CSS (well, it's CSS inside of a JavaScript string) - so you need to escape the backslash in a JavaScript string, it's just how JavaScript works. I don't know how it's even working in dev, since it shouldn't. You might want to read up on strings in JavaScript, if you're interested. But a backslash is an escape character. To have a backslash in the output, you need a backslash to escape another backslash - two backslashes. |
I understand how escaping in strings is working. But if you are provided a real css to be minified either minifier should respect its single backslashes or css string should be parsed by regexp to replace single backslashes to double once. |
In example cd to |
To run it in dev you need to do some steps: npm install tsd -g
npm install
npm start |
@tandu It's not a TypeScript bug if it's in CSS. You should log the issue in the minifier repo you've mentioned. |
Yes, I think you are right, I will talk with them. |
@tandu Looks like it's caused in https://github.com/ludohenin/gulp-inline-ng2-template/blob/master/parser.js#L164-L167, they are just printing the backslashes back into JS without any additional escaping. They need to replace every backslash with two backslashes. |
as I understand originally it appear when @Component({
template: '',
styles: [`
smile:before {
content: "\200B";
}
`]
})
class SampleComponent {} if yes then from my reading of the ES6 spec seem that
|
Or as you said |
Yes. Sounds like TypeScript could give a compiler error on the escape sequence, and that'll make the issue more obvious to consumers. Need to make sure |
This looks fixed in latest. |
Is compressed to
mgechev/angular-seed#390
The text was updated successfully, but these errors were encountered: