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

Fix issue where el.splice could not clear full array #5051

Merged
merged 4 commits into from
Jan 31, 2018

Conversation

TimvdLippe
Copy link
Contributor

The gist of the issue is that, depending on the number of arguments passed on to array.splice, splice does different things. We were eagerly setting start to 0 and passing all 3 arguments. Instead, check which case we actually have and fix the case when only start is passed in.

Reference Issue

Fixes #5032

//
let ret;
// Omit any additional arguments if they were not passed in
if (start !== undefined && !deleteCount && !items.length) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For simplicity, let's just check if arguments.length ==2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed 👍

Copy link
Contributor

@sorvell sorvell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one little nit and then looks good.

@TimvdLippe
Copy link
Contributor Author

@sorvell I have updated the if-condition. Could you approve this PR?

@kevinpschaaf kevinpschaaf merged commit 4c8d255 into master Jan 31, 2018
@kevinpschaaf kevinpschaaf deleted the array-splice-only-start branch January 31, 2018 18:46
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 this pull request may close these issues.

Omitting deleteCount, this.splice() acts different from array.splice()
4 participants