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

DefineList.sort fires length event on empty list #404

Open
m-mujica opened this issue Nov 7, 2018 · 0 comments
Open

DefineList.sort fires length event on empty list #404

m-mujica opened this issue Nov 7, 2018 · 0 comments

Comments

@m-mujica
Copy link
Contributor

m-mujica commented Nov 7, 2018

const items = new DefineList({ i: 1 });

items.on('length', () => {
  console.log(items.sort());
});

items.splice(0, 1);

This code causes an infinite loop. I had a similar thing in component with a calls sort in its source list. E.g:

list: {
  get(lastSetValue) {
    return lastSetValue.sort(comparator);
  }
}

I wonder if DefineList.sort should not fire the event and early return if the list is empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants