justin-schroeder / arrow-js

Reactivity without the framework
https://arrow-js.com
MIT License
2.32k stars 50 forks source link

Fix reactive array splice bug when called with single argument #92

Closed thomasperi closed 4 months ago

thomasperi commented 8 months ago

Fixed a bug that caused the splice method on reactive arrays to behave differently from Array.prototype.splice.

When Array.prototype.splice receives only one argument, all the elements from that index to the end of the array get deleted. But if it receives undefined as its second argument, it treats it as zero, and doesn't delete any elements.

This fix changes reactive splice so that when it only receives one argument, it only passes one argument on to Array.prototype.splice.

Also added a test case for the bug fix, and renamed the file reactive.spec.ts.ts to reactive.spec.ts because the double .ts.ts extension was preventing it from running.

vercel[bot] commented 8 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
arrow-js ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 26, 2023 11:39pm
justin-schroeder commented 4 months ago

Thanks!