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

splicein DefineListt removing undefined values in source array #471

Open
1 of 5 tasks
mikemitchel opened this issue Sep 11, 2019 · 0 comments
Open
1 of 5 tasks

splicein DefineListt removing undefined values in source array #471

mikemitchel opened this issue Sep 11, 2019 · 0 comments
Assignees
Labels

Comments

@mikemitchel
Copy link

mikemitchel commented Sep 11, 2019

How often can you reproduce it?

  • Always
  • Sometimes
  • Rarely
  • Unable
  • I didn’t try

Description:
If the source array for a new DefineList contains only values of undefined at each index, it passes the allSame test here when calling splice:

can-define/list/list.js

Lines 294 to 297 in ea827f8

// Now lets check if anything will change
if (this[i + index] !== args[listIndex]) {
allSame = false;
}

as it thinks nothing will change, and ends up returning a DefineList of length 0. As long as at least one element in the source array is not undefined it works as expected.

var undefinedList = new DefineList([undefined, undefined])
console.log('so much empty', undefinedList.length) //=> 0

See this codepen example:
https://codepen.io/mikemitchel/pen/eYOMwmE

Expected results:
I expected in the first example of the codepen to have a DefineList of length 2, with the value at each index being undefined.

Environment:

Software Version
can-define version "^2.7.10"
Browser Chrome Version 76.0.3809.132 (Official Build) (64-bit)
Operating system MacOS 10.14.6 (18G95)
@mikemitchel mikemitchel self-assigned this Sep 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant