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

unexpected behaviors for array index out of valid array length when set and del #718

Closed
hyf0 opened this issue Jun 1, 2021 · 1 comment · Fixed by #719
Closed

unexpected behaviors for array index out of valid array length when set and del #718

hyf0 opened this issue Jun 1, 2021 · 1 comment · Fixed by #719

Comments

@hyf0
Copy link
Contributor

hyf0 commented Jun 1, 2021

It's similar to vuejs/core#3816 but not exactly.

@hyf0
Copy link
Contributor Author

hyf0 commented Jun 1, 2021

set

set(ref([]).value, Math.pow(2, 32), 0) will throw error Uncaught RangeError: Invalid array length

if (isArray(target) && isValidArrayIndex(key)) {
target.length = Math.max(target.length, key)

del

splice does not work on index out of valid array length.

if (Array.isArray(target) && isValidArrayIndex(key)) {
target.splice(key, 1)

foo = [];
foo[Math.pow(2, 32)] = 0;
foo.splice(Math.pow(2, 32), 1);
(Math.pow(2, 32) in foo) // => true;

@antfu antfu closed this as completed in #719 Jun 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant