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

CreateReducer.js uses "startsWith" which is unsupported in IE11 #4126

Closed
soavie opened this issue Jul 9, 2018 · 16 comments
Closed

CreateReducer.js uses "startsWith" which is unsupported in IE11 #4126

soavie opened this issue Jul 9, 2018 · 16 comments
Labels

Comments

@soavie
Copy link
Contributor

soavie commented Jul 9, 2018

Are you submitting a bug report or a feature request?

bug report

What is the current behavior?

Unable to input text into Redux Form Field in IE11. Results in "TypeError: Object doesn't support property or method 'startsWith'"

What is the expected behavior?

It should be possible to input text without throwing any errors in IE11.

What's your environment?

redux-form 7.4.2
IE11

Other information

Line causing the error:
https://github.com/erikras/redux-form/blob/v7.4.2/src/createReducer.js#L47

  if (path.startsWith('values')) {

Commit that introduced the error:
a97606f

String.prototype.startsWith() browser support:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith

We've been able to work around this by using core-js to polyfill the feature.

@gustavohenke
Copy link
Collaborator

Thanks for the heads up. That seems to have been introduced in v7.4.0, and should be an easy fix, if you would like to go for it 🙂

@chrisjlee
Copy link

chrisjlee commented Jul 10, 2018

Any preference how this is done?

I was thinking on using this polyfill from MDN. is this polyfill sufficient?

if (!String.prototype.startsWith) {
	String.prototype.startsWith = function(search, pos) {
		return this.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
	};
}

@gustavohenke
Copy link
Collaborator

Adding polyfills to Redux Form wouldn't be a good idea, but if you mean using its implementation, then yeah, that's an option.

An even better one would be to use a regular expression, like /^values/.test(path), as then others don't need to guess where the magic number of the .substr() call is coming from.

@chrisjlee
Copy link

Yes implementation-wise. Thank you @gustavohenke !

@gustavohenke
Copy link
Collaborator

PR #4128 with the fix has been merged. Watch out for new releases!

@ldthorne
Copy link

Hey @gustavohenke @erikras , do you know when there will be a new release with this included? I'd like to use this fix as I'm hitting the same issue, but haven't been able to because there's no release for it yet. Thanks!

@rebebop
Copy link

rebebop commented Aug 23, 2018

@erikras @gustavohenke any update on this?

@DonWasyl
Copy link

DonWasyl commented Sep 4, 2018

npm package isn't updated from 3 months, this fix was merged 2 months ago
@gustavohenke, @erikras is possible to update package in npm?

@gustavohenke
Copy link
Collaborator

I don't control the release cycle.

@abumalick
Copy link

@erikras We need a release to fix this bug please

@leocristofani
Copy link

This issue is marked as closed, but it persists because #4128 has been merged into master, but not released yet. Any idea when this is going to be released? Thanks very much!

@davidgtu
Copy link

davidgtu commented Dec 3, 2018

@soavie I'm having this issue as well. how did you get around this using core-js?

@abumalick
Copy link

import 'core-js/modules/es6.string.starts-with'; // redux-form
in the beginning of your app

@shorif2000
Copy link

shorif2000 commented Dec 5, 2018

I am having this issue in 7.4.2. i have tried to add import 'core-js/modules/es6.string.starts-with'; but it has not helped. my form also contains ['object Object'] and this occurs when i try to browse to another component/path. it is not browser dependant.

@erikras
Copy link
Member

erikras commented Dec 11, 2018

Published fix in v8.0.0.

@lock
Copy link

lock bot commented Apr 2, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests