core icon indicating copy to clipboard operation
core copied to clipboard

fix(reactivity): enable trigger when use str to set length of arr

Open bcq028 opened this issue 3 years ago • 2 comments

js allows use string to set length of array. The original code uses an implicit conversion that requires newValue to be a number as key's type is string. If newValue is also a string, string comparison are performed instead of number comparison. The string comparison is lexicographical order, so "10"< "2", causing the length to be set to 2 but watch element at 10 will not be triggered

bcq028 avatar Oct 03 '22 04:10 bcq028

That's a strange behavior of JS, TIL. 😅

antfu avatar Oct 03 '22 07:10 antfu

A new user left a comment. This user must be approved by a Netlify team owner before comments can be displayed.

Approve this user

netlify[bot] avatar Oct 04 '22 09:10 netlify[bot]