Skip to content

Commit ed87af7

Browse files
committed
add tracking dataset for bound checkboxes
1 parent a93f192 commit ed87af7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

web_src/js/markup/tasklist.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/**
22
* Attaches `input` handlers to markdown rendered tasklist checkboxes in comments.
3-
* The code assumes the checkbox will be initially disabled by the markdown renderer.
43
*
54
* When a checkbox value changes, the corresponding [ ] or [x] in the markdown string
65
* is set accordingly and sent to the server. On success it updates the raw-content on
@@ -12,9 +11,11 @@ const preventListener = (e) => e.preventDefault();
1211
export function initMarkupTasklist() {
1312
for (const el of document.querySelectorAll(`.markup[data-can-edit=true]`) || []) {
1413
const container = el.parentNode;
15-
const checkboxes = el.querySelectorAll(`.task-list-item input[type=checkbox][disabled]`);
14+
const checkboxes = el.querySelectorAll(`.task-list-item input[type=checkbox]`);
1615

1716
for (const checkbox of checkboxes) {
17+
if (checkbox.dataset.editable) return;
18+
checkbox.dataset.editable = 'true';
1819
checkbox.addEventListener('input', async () => {
1920
const checkboxCharacter = checkbox.checked ? 'x' : ' ';
2021
const position = parseInt(checkbox.dataset.sourcePosition) + 1;

0 commit comments

Comments
 (0)