-
Notifications
You must be signed in to change notification settings - Fork 24.1k
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
string startsWith
produces false negatives
#19699
Comments
@TheSavior Thanks for the suggestion. However, I don't see any difference in the version of JavaScriptCore between 0.55 and 0.56. Both https://github.com/facebook/react-native/blob/0.55-stable/ReactAndroid/build.gradle and https://github.com/facebook/react-native/blob/0.56-stable/ReactAndroid/build.gradle use WebKit/webkit/38b15a3ba3c1b0798f2036f7cea36ffdc096202e. Are you using react-native in development mode? I ask because I see in the documentation that that uses V8 instead of JavaScriptCore. I also tried this in Chrome's JavaScript console (which uses V8), and got the expected result (3 |
https://github.com/WebKit/webkit/tree/38b15a3ba3c1b0798f2036f7cea36ffdc096202e is from October 13, 2014. It's entirely possible there was a bug in WebKit that has been fixed sometime in the past three years. I was able just now to test in Safari, and Safari's JavaScript console produces the correct result. |
Ah, yeah, this sounds like a bug in JSC. |
Ok, thanks! Yeah I saw that JavaScriptCore hasn't been updated since the beginning of react-native. That'll be a bear to upgrade carefully. D'oh. Oh well. Maybe it'd be worth noting in the "JavaScript Environment" documentation page which version is in use (and its release date)? |
seem like startswith cant work well if a str contain Chinese |
Node: 8.12.0 |
@MrPluto and @dmaksimovic, React Native 0.56, 0.57, and 0.58 all continued to use the same JSC. They finally updated it, though. See #19737 (comment) I double checked, and you can see the change live now in 0.59. https://github.com/facebook/react-native/blob/0.58-stable/ReactAndroid/build.gradle#L148 shows the old JSC, and https://github.com/facebook/react-native/blob/0.59-stable/ReactAndroid/build.gradle#L136 is now evergreen. I haven't tried upgrading yet myself, but it seems that should fix this issue. |
react-native info
in your terminal and paste its contents under "Environment"share an app that reproduces the issue using https://snack.expo.io/
Environment
Description
I have a component that was filtering a list of suggestions, and I stumbled on a strange bug. The list was mysteriously not including some items it should have, and I eventually figured out that the Javascript engine was producing incorrect results on strings that had UTF8 characters in them. That is,
someString.startsWith(someOtherString)
was producingfalse
when it shouldn't have.Steps to Reproduce
Note the Unicode apostrophe in the last case.
If it makes a difference, I used
create-react-native-app
to bootstrap my app, and I'm running it in Expo.Expected Behavior
Actual Behavior
The text was updated successfully, but these errors were encountered: