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

$inspect shows duplicate elements in arrays when using splice #15102

Open
samausir opened this issue Jan 24, 2025 · 1 comment
Open

$inspect shows duplicate elements in arrays when using splice #15102

samausir opened this issue Jan 24, 2025 · 1 comment

Comments

@samausir
Copy link

Describe the bug

I have an array let arr = $state(['a', 'b', 'c']). When I arr.splice(1, 1), $inspect(arr) first shows me ['a', 'c', 'c'] before showing the correct version, which is ['a', 'c'].

This was raised in #13494 before and was fixed, but it apparently has made a comeback.

Reproduction

https://svelte.dev/playground/0955025b01db4aa99efcd441351b33e9?version=5.19.2

Logs

init 
(3) [ "a" ,"b" ,"c" ]
update 
(3) [ "a" ,"c" ,"c" ]
update 
(2) [ "a" ,"c" ]

System Info

N/A

Severity

annoyance

@paoloricciuti
Copy link
Member

This is kinda of expected since it's how the browser "apply" slice...we could probably use the same trick Rich used in #15073 but i'd say let's wait to see if #15069 is merged first so that we can reuse that code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants