* Returns the index of an element within its parent for a selected set of * elements * @param {HTMLElement} el * @param {selector} selector * @return {number}
(el, selector)
| 371 | * @return {number} |
| 372 | */ |
| 373 | function index(el, selector) { |
| 374 | let index = 0; |
| 375 | |
| 376 | if (!el || !el.parentNode) { |
| 377 | return -1; |
| 378 | } |
| 379 | |
| 380 | /* jshint boss:true */ |
| 381 | while (el = el.previousElementSibling) { |
| 382 | if ((el.nodeName.toUpperCase() !== 'TEMPLATE') && el !== Sortable.clone && (!selector || matches(el, selector))) { |
| 383 | index++; |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | return index; |
| 388 | } |
| 389 | |
| 390 | /** |
| 391 | * Returns the scroll offset of the given element, added with all the scroll offsets of parent elements. |
no test coverage detected
searching dependent graphs…