Skip to content

Fix Blob.slice end handling when start is omitted - #59533

Merged
vzaidman merged 1 commit into
react:mainfrom
Shubham-Padkonde:fix/blob-slice-omitted-start
Oct 28, 2026
Merged

vzaidman merged 1 commit into
react:mainfrom
Shubham-Padkonde:fix/blob-slice-omitted-start

Conversation

@Shubham-Padkonde

Copy link
Copy Markdown
Contributor

Summary:

new Blob(['abcdef']).slice(undefined, 3) currently returns all six bytes instead of the first three. End normalization is inside the numeric-start branch, so an omitted start causes the end argument to be ignored. This also affects zero/negative ends and slices of existing views.

Default start to zero so these calls follow the existing range calculation. Numeric-start behavior and the optional public parameter remain unchanged. This matches the File API slicing algorithm.

Changelog:

[GENERAL] [FIXED] - Respect the end offset in Blob.slice when the start argument is undefined.

Test Plan:

  • Added seven cases covering positive, zero, negative, out-of-range and omitted ends, plus a nested slice with a nonzero source offset. Five fail on unchanged base 866034f; all pass with the fix.
  • yarn test packages/react-native/Libraries/Blob packages/react-native/Libraries/Network packages/react-native/Libraries/WebSocket --runInBand --watchman=false: 55 tests pass across five suites on Windows, Node 24.15.0.
  • Prettier and ESLint (--max-warnings 0) pass on both changed files; git diff --check passes.
  • yarn build-types translates the package declarations successfully, with byte-identical generated Blob declarations before/after the fix. Its later API snapshot step fails on a Windows path embedded in an ActionSheetIOS identifier; the same failure reproduces with unchanged Blob source. No generated files changed.
  • Full Flow checks, native builds and the full JavaScript suite were not run.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 27, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Oct 27, 2026
@vzaidman
vzaidman self-requested a review October 27, 2026 18:04
@github-actions

Copy link
Copy Markdown

Visual regression

2 visual difference(s) at a318911b3098. Visual differences need maintainer approval. Review the report, then apply visual-change-approved.

ios button/disabled/default: Changed, 280048 px (11.234%)

diff

Expected and Captured
Expected Captured
expected captured

ios scroll-view/horizontal-scroll-to/end: Changed, 69504 px (18.123%)

diff

Expected and Captured
Expected Captured
expected captured

@vzaidman
vzaidman merged commit 7619e9c into react:main Oct 28, 2026
109 of 114 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants