Closed
Description
line 66 of setInnerHTML node.innerHTML = '\uFEFF' + html;
is minified as e.innerHTML = "" + t;
in react.min.js and react-with-addons.min.js. An exception is thrown on on line 71 because textNode.data
is undefined
.
Here's a repro that's modified from the basic example
<script src="../../build/react.min.js"></script>
<script>
var Container = React.createClass({
render: function(){
return React.DOM.div(null, this.props.children);
}
});
var ExampleApplication = React.createClass({
render: function() {
var elapsed = Math.round(this.props.elapsed / 100);
var seconds = elapsed / 10 + (elapsed % 10 ? '' : '.0' );
var message =
'React has been successfully running for ' + seconds + ' seconds.';
return React.DOM.p(null, message);
}
});
React.renderComponent(
Container(null,
ExampleApplication({elapsed: new Date().getTime()}),
document.getElementById('container')
));
</script>
Activity
sophiebits commentedon Sep 26, 2014
What encoding are you serving your HTML with? My guess is if you add
<meta charset="utf-8">
to your<head>
then this will work correctly, though maybe we should use only ASCII chars in our minified builds.sophiebits commentedon Sep 26, 2014
Never mind, I see that the character is actually missing. Maybe a bug in uglifyjs?
syranide commentedon Sep 26, 2014
@spicyj As it's encoded the charset is irrelevant unless uglifyjs decodes it, being zero-width/invisible I imagine it would look like nothing is there... but it really seems like nothing is there. Very weird.
syranide commentedon Sep 26, 2014
https://github.com/mishoo/UglifyJS2/blob/master/lib/parse.js#L209
Is apparently the culprit, but it doesn't seem like it should be. Perhaps uglifyjs decodes strings first and then strips for some reason...
syranide commentedon Sep 26, 2014
mishoo/UglifyJS#556
syranide commentedon Sep 26, 2014
Hmm, this is interesting, this problem only surfaces if you double-uglify the source, perhaps something is wrong in our build-process?
syranide commentedon Sep 26, 2014
PR #2249
syranide commentedon Sep 26, 2014
@cascadian I should add; if this is a priority for you simply replace
.innerHTML=""
with.innerHTML="!"
(you can replace"\uFEFF"
with"!"
in the source too) and it should work.zpao commentedon Sep 29, 2014
Yes, we double uglify to remove dead requires from the tree (see #1933).
dennis-johnson-dev commentedon Dec 18, 2014
Is this still an issue? I'm seeing it with react-with-addons.min.js v 0.12.2 in IE8.
17 remaining items