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

Svelte 5: Monkeypatching introduced in #11610 has broken array_prototype.lastIndexOf() #11756

Closed
marklbarlow opened this issue May 23, 2024 · 0 comments · Fixed by #11766
Closed
Labels
Milestone

Comments

@marklbarlow
Copy link

Describe the bug

The introduction of equality.js in #11610 seems to have broken the behaviour of lastIndexOf() from 5.0.0-next.134 onwards.

Specifically, from v134 omitting the second argument (fromIndex) seems to default as 0 / falsy rather than the last index of the array.

const arr = [0, 1, 2];
console.log('Without fromIndex:', arr.lastIndexOf(2));
console.log('With fromIndex:', arr.lastIndexOf(2, arr.length - 1));

Before:

Without fromIndex: 2
With fromIndex: 2

After:

Without fromIndex: -1
With fromIndex: 2

Thanks for all the hard work on this. Looking forward to the final release.

Reproduction

As above.

Logs

No response

System Info

System:
    OS: macOS 11.7.10
    CPU: (4) x64 Intel(R) Core(TM) M-5Y71 CPU @ 1.20GHz
    Memory: 49.04 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 20.3.0 - /usr/local/bin/node
    npm: 9.6.7 - /usr/local/bin/npm
  Browsers:
    Chrome: 124.0.6367.210
    Safari: 16.6.1
  npmPackages:
    svelte: ^5.0.0-next.134 => 5.0.0-next.134

Severity

blocking all usage of svelte

@dummdidumm dummdidumm added this to the 5.0 milestone May 23, 2024
@dummdidumm dummdidumm added the bug label May 23, 2024
dummdidumm pushed a commit that referenced this issue May 24, 2024
Fixes #11756

lastIndexOf seems to be using arguments internally so passing undefined is different from not passing it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants