Skip to content

Commit

Permalink
Replace matchAll with exec
Browse files Browse the repository at this point in the history
Summary:
When using the `g` modifier on the regex, match and matchAll's behaviour is equivalent, and match has better backwards compatibility on older iOS versions.

Changelog: [General][Fixed] Fixed a backwards compatibility issue with AnimatedInterpolation

Reviewed By: yungsters

Differential Revision: D41879036

fbshipit-source-id: 240dda85ef0de8e27452846c77114ac46823f74f
  • Loading branch information
motiz88 authored and facebook-github-bot committed Dec 13, 2022
1 parent 822396d commit 9b280ad
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Libraries/Animated/nodes/AnimatedInterpolation.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ function mapStringToNumericComponents(
} else {
const components: Array<string | number> = [];
let lastMatchEnd = 0;
for (const match of input.matchAll(numericComponentRegex)) {
let match: RegExp$matchResult;
while ((match = (numericComponentRegex.exec(input): any)) != null) {
if (match.index > lastMatchEnd) {
components.push(input.substring(lastMatchEnd, match.index));
}
Expand Down Expand Up @@ -245,7 +246,6 @@ function createStringInterpolation(
if (!isColor) {
return input => {
const values = interpolations.map(interpolation => interpolation(input));
console.log({values});
let i = 0;
return outputRange[0].components
.map(c => (typeof c === 'number' ? values[i++] : c))
Expand Down

0 comments on commit 9b280ad

Please sign in to comment.