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
Tab escaping breaks minified version underscore 1.6.0 using Grunt uglify #1537
Comments
Hi @woazala! What version of uglify is in use and with what settings? We use uglify to produce |
As you said, duplicate of #818. |
@michaelficarra woazala said it was similar not that it was a duplicate. #818 wasn't dealing with UglifyJS which is an important distinction as it's 1) used by Underscore and 2) really popular. I found the open UglifyJS issue here. It has a PR too but zero activity (imma 👍 it) |
@woazala I'm not sure how the literal tab would affect anything. Could it be related to mod_pagespeed or Wordpress which replaced tabs with empty strings |
Also worth noting the OP in the Uglify issue stated that replacing |
Actually, I worked around it. The issue is in how Underscore replaces the characters: _.template('\t', {});
// throws because it generated "\undefined", an invalid escape sequence The To avoid it just have: .replace(escaper, function(match) {
var part = escapes[match];
return part ? '\\' + escapes[match] : match;
}); or remove |
Ok so @braddunbar and I Matlock'ed, or is it Columbo'ed, this back to early whitespace munging. The tab does not need to be escaped. |
Yep yep. Pull incoming with removal. |
Pulled in #1538. |
The uglify bug still stands but the tab escape was removed in 3526d4b anyway. |
Thanks for finding the problem @jdalton Sorry for not helping, I was away from my email. |
No problem. Thanks for reporting @woazala! |
I am using grunt uglify to compile and minifiy my assets and I have a similar problem as in #818 .
The fix I made in development version at this lines:
// Certain characters need to be escaped so that they can be put into a
// string literal.
var escapes = {
"'": "'",
'': '',
'\r': 'r',
'\n': 'n',
'\t': 't',
'\u2028': 'u2028',
'\u2029': 'u2029'
};
was to change \t to \x09:
var escapes = {
"'": "'",
'': '',
'\r': 'r',
'\n': 'n',
'\x09': 't',
'\u2028': 'u2028',
'\u2029': 'u2029'
};
And that fix it.
The text was updated successfully, but these errors were encountered: