can-connect
can-connect copied to clipboard
Behavior reordering breaks when user behaviors are inserted.
https://jsbin.com/voraxahuje/1/edit?html,js,output
Ordering in can-connect uses an Array sort comparator that checks sortedIndex (the index of the behavior in connect.order) against sortedIndex if it exists on both items, or originalIndex (the index of the behavior in the original array) against originalIndex if missing on either item. this is to ensure that behaviors which depend on other behaviors are ordered to preserve these dependencies.
If a user-defined behavior is inserted between two behaviors in the wrong sort order, that sort order will be incorrect, because the sort comparator relies on items with sortedIndex to be adjacent to each other and the user-defined behavior does not have a sortedIndex.