Skip to content
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

Shim for Function::bind throws error for non-minified React #390

Closed
mendelk opened this issue Feb 24, 2016 · 10 comments
Closed

Shim for Function::bind throws error for non-minified React #390

mendelk opened this issue Feb 24, 2016 · 10 comments
Assignees

Comments

@mendelk
Copy link

mendelk commented Feb 24, 2016

I apologize if this is reported elsewhere, or if it's the intended behavior, or not es5-shim's fault (which it probably isn't), but I can't be the only one dealing with this!

The problem is that this throws an error in IE8:

<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.5/es5-shim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.5/es5-sham.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.0/react.js"></script>
<script>
  var Hello = React.createClass({
    displayName: "Hello",
    render: function() {
      return "<p>Hello</p>";
    }
  });
</script>

As far as I can tell, this is because of this code:

injectedMixins.forEach(
  mixSpecIntoComponent.bind(null, Constructor)
);

Now, es5-shim uses isCallable to determine if something can be binded.

For some reason, mixSpecIntoComponent fails the isCallable test, in particular because it passes the isES6ClassFn(value) test, thus throwing this error.

What gives?

Strangely, the problem does not occur when using the minified version.

Note FWIW: I'm testing this on IE8 on Win7 via VirtualBox VM from a MBP

Thank you so much for this awesome lib!

@ljharb
Copy link
Member

ljharb commented Feb 25, 2016

isES6ClassFn should only be able to pass when something is a native "class" - which shouldn't be possible in IE 8.

Thank you for the jsbin - I'll take a look at this this weekend and see if I can figure it out. What's likely happening is that the non-minified version is triggering the regex in isCallable but the minified version is not.

@ljharb ljharb self-assigned this Feb 25, 2016
@mendelk
Copy link
Author

mendelk commented Feb 25, 2016

Thanks. Let me know if there's anything I can do to help.

@InfamousVague
Copy link

Just leaving a note here to follow this issue, having the same issue in our project (We think from f2236f6) getting TypeError: Function.prototype.bind called on incompatible function mixSpecIntoComponent(Constructor, spec) Will report back here if we find anything that can help solve this issue.

@kurttheviking
Copy link

I've confirmed this on actual WinXP/IE8 as well for unminified versions (yes, my team really does support this configuration...fortunately only dev builds on not minified)

@ljharb
Copy link
Member

ljharb commented Feb 27, 2016

Thanks everybody! I promise I'll have a fix out this weekend.

@InfamousVague
Copy link

You da man @ljharb!

ljharb added a commit to inspect-js/is-callable that referenced this issue Feb 28, 2016
@ljharb
Copy link
Member

ljharb commented Feb 28, 2016

Figured out the issue in is-callable. It's a stupid mistake in a regex. Will have a release of both out shortly.

@ljharb ljharb closed this as completed in cf85dd4 Feb 28, 2016
@ljharb
Copy link
Member

ljharb commented Feb 28, 2016

Released as v4.5.7

@mendelk
Copy link
Author

mendelk commented Feb 29, 2016

Confirming that issue has been fixed. Thanks @ljharb!

@kurttheviking
Copy link

thanks @ljharb -- confirmed on ye olde xp machine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants