Mobius1 / Selectable

Touch enabled selectable plugin inspired by the jQuery UI widget.
MIT License
144 stars 21 forks source link

Bug in _highlight #59

Closed SapientGuardian closed 1 year ago

SapientGuardian commented 1 year ago

https://github.com/Mobius1/Selectable/blob/0.19.0/selectable.js#L1707

  if (item.selecting) {
                        classList.remove(el, o.classes.selecting);
                        item.selecting = false;
                        if (cmd && item.startselected) {
                            classList.add(el, o.classes.selected);
                            item.selected = true;
                        } else {
                            if (item.startselected && !o.toggle) {
                                classList.add(el, o.classes.deselecting);
                                item.deselecting = true;
                            }
                        }
                    }
                    if (el.selected) {
                        if (!cmd) {
                            if (!item.startselected) {
                                classList.remove(el, o.classes.selected);
                                item.selected = false;

                                classList.add(el, o.classes.deselecting);
                                item.deselecting = true;
                            }
                        }
                    }

I don't think this check for el.selected is correct; I believe it should be item.selected. el would be the DOM element, which doesn't appear to ever get .selected set on it.