Skip to content

Commit 3eba7a6

Browse files
mr-migKristján Oddsson
authored and
Kristján Oddsson
committed
Change the logic for calculating item position
Use tagName === `LI` to calculate item position within a list
1 parent a069828 commit 3eba7a6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/task-lists-element.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ 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 listItems = Array.from(list.children).filter(el => el.classList.contains('task-list-item'))
135+
const listItems = Array.from(list.children).filter(el => el.tagName === 'LI')
136136
const index = item ? listItems.indexOf(item) : -1
137137
return [listIndex(list), index]
138138
}

0 commit comments

Comments
 (0)