-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
React uses the encoded "zero width no-break space" "\uFEFF" for an IE8 workaround:
https://github.com/facebook/react/blob/716742dcd7fc7521737c94e7f0ed9d876658a6b7/src/browser/ui/dom/setInnerHTML.js#L66
However, it seems that UglifyJS strips it from the minified build breaking the workaround and throwing an exception. The culprit is apparently:
https://github.com/mishoo/UglifyJS2/blob/master/lib/parse.js#L209
EDIT: Upon further testing it seems that the React build might be double-uglifying for some reason, as I can only reproduce this myself with two uglify passes. It's still very much an issue though as someone could likely concatenate a minified build with their own code and minify that, the error would then show up again.
If I remove it it works as expected, so apparently decoded \uFEFF (even in strings) are removed. We should probably be using \u2060 but due to the decoding of unicode chars even that is not entirely safe. So an option to not decode unicode chars would be preferable as it otherwise requires <meta charset="utf-8"> or <script charset="utf-8" ...>, which many aren't aware of.
Repro: Uglify twice, alert("\uFEFF".length) (1) -> alert("<FEFF>".length) (1) -> alert("".length) (0)
cc @mishoo