Skip to content

DefineList.sort fires length event on empty list #404

Open
@m-mujica

Description

@m-mujica
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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions