Skip to content

Commit 63e5795

Browse files
Compute the index of the current task list item using only other task list items.
1 parent f6888ca commit 63e5795

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/task-lists-element.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ function position(checkbox: HTMLInputElement): [number, number] {
132132
const list = taskList(checkbox)
133133
if (!list) throw new Error('.contains-task-list not found')
134134
const item = checkbox.closest('.task-list-item')
135-
const index = item ? Array.from(list.children).indexOf(item) : -1
135+
const index = item
136+
? Array.from(list.children)
137+
.filter(el => el.classList.contains('task-list-item'))
138+
.indexOf(item)
139+
: -1
136140
return [listIndex(list), index]
137141
}
138142

0 commit comments

Comments
 (0)