-
-
Notifications
You must be signed in to change notification settings - Fork 225
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
Allow for exceptions in string concat inlining #382
Comments
Couple more thoughts:
//= babili-no-concat-start
div.innerHTML = '<scri' + 'pt></scri' + 'pt>';
//= babili-no-concat-end |
If you decide to go that route, note that just On the other hand, (This is what jsesc’s See https://mathiasbynens.be/notes/etago & https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-contents-of-script-elements for more background. I see your point re: “not sure if it’s a minifier’s job to do this”. Pragmatically speaking though, it makes sense to (at least) provide an option to enable such escaping (or to avoid concatenation, but that seems harder and less ideal). I remember having the same discussion on the UglifyJS repository before their |
babel-generator already uses jsesc, so it could easily hook in to jsesc’s |
Google Closure escapes script tags and HTML comments by default. I thought Uglify also escapes such things by default, but apparently it needs a flag:
|
This will be addressed by babel/babel#5581 |
Originally brought up by @spicyj.
Since
'</' + 'script'
is a pretty common way of avoiding "</script" strings inside script tags, we need to figure out how to allow for cases like this.Alternatively, we can replace "</" sequence with unicode representation (
\u003c\u002f
) but I'm not sure if it's minifier's job to do this.One immediate solution I see is to add an option of blacklisting concatenable strings:
It's unclear which logic to use for a list of blacklisted strings — when ALL match or when ANY match? If we use ANY then we could be missing out on concatenating "</div", "</some:component", etc.
If we were to go with escaping:
But then it feels like something Babel (Babel's printer, actually) should be taking care of.
I'm curious to hear what @mathiasbynens thinks.
/cc @hzoo
The text was updated successfully, but these errors were encountered: