react icon indicating copy to clipboard operation
react copied to clipboard

Minified version broken in IE8

Open cascadian opened this issue 12 years ago • 21 comments

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>

cascadian avatar Sep 26 '14 05:09 cascadian

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 avatar Sep 26 '14 05:09 sophiebits

Never mind, I see that the character is actually missing. Maybe a bug in uglifyjs?

sophiebits avatar Sep 26 '14 05:09 sophiebits

@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 avatar Sep 26 '14 08:09 syranide

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 avatar Sep 26 '14 08:09 syranide

mishoo/uglifyjs2#556

syranide avatar Sep 26 '14 09:09 syranide

Hmm, this is interesting, this problem only surfaces if you double-uglify the source, perhaps something is wrong in our build-process?

syranide avatar Sep 26 '14 09:09 syranide

PR #2249

syranide avatar Sep 26 '14 09:09 syranide

@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.

syranide avatar Sep 26 '14 13:09 syranide

this problem only surfaces if you double-uglify the source, perhaps something is wrong in our build-process

Yes, we double uglify to remove dead requires from the tree (see #1933).

zpao avatar Sep 29 '14 19:09 zpao

Is this still an issue? I'm seeing it with react-with-addons.min.js v 0.12.2 in IE8.

dennis-johnson-dev avatar Dec 18 '14 22:12 dennis-johnson-dev

Ping, this is resolved in uglifyjs/master now at least. React should go the way of #2340 if you ask me though.

syranide avatar Jan 04 '15 23:01 syranide

This issue, although easily fixed by @syranide's DIY patch, still exists in http://fb.me/react-0.13.1.min.js and any other FB-packaged react.min.js. :| Sorry to be a nag. In the end this is all IE8's fault anyway.

markplindsay avatar Mar 17 '15 14:03 markplindsay

@markplindsay I haven't verified, but this was fixed upstream in UglifyJS some time ago so it should have solved itself... @zpao is it possible you're running the build process with an older UglifyJS?

syranide avatar Mar 17 '15 14:03 syranide

@syranide, thanks for your followup. I am looking at a react-0.13.1.min.js I wgot from http://fb.me/react-0.13.1.min.js. Changing e.innerHTML="" to e.innerHTML="!" by adding the ! at Line 15, Column 17852 still fixes the issue.

markplindsay avatar Mar 17 '15 14:03 markplindsay

@zpao Ah, apparently we've locked the uglifyjs dependency to 2.4.0 whereas the fix is in 2.4.17 (or perhaps the one after it, not sure what the tag means in https://github.com/mishoo/UglifyJS2/commit/24bc09b79bf9ca3a09eef4f536e7637568f7097a). There's no reason not to update the dependency right?

syranide avatar Mar 17 '15 14:03 syranide

We just got bit by this issue. Please update uglify!

mockdeep avatar Apr 10 '15 18:04 mockdeep

AFAIK no reason not to upgrade. @syranide want to send a PR to the 0.13-stable branch? (I forget how to update shrinkwrap files properly though…)

sophiebits avatar Apr 10 '15 19:04 sophiebits

Send to master and I'll pull it in with other things

cheers, Paul

On Apr 10, 2015, at 12:26 PM, Ben Alpert <[email protected]mailto:[email protected]> wrote:

AFAIK no reason not to upgrade. @syranidehttps://github.com/syranide want to send a PR to the 0.13-stable branch? (I forget how to update shrinkwrap files properly though…)

— Reply to this email directly or view it on GitHubhttps://github.com/facebook/react/issues/2247#issuecomment-91658188.

zpao avatar Apr 10 '15 19:04 zpao

Just confirmed that this is correct in the minified build now. We'll ship 0.13.2 this week with the fix.

zpao avatar Apr 13 '15 22:04 zpao

will 0.12.x get rebuild too?

ledowong avatar Apr 14 '15 11:04 ledowong