Skip to content

Commit 5af0e5e

Browse files
committed
fix: disallow nested data-checkswipe
Handlers must be applied from bottom-up in order to get some effect of nested groups that do not interact with each other. Even so, the CSS enlarges all checkboxes, even if they "shouldn't"
1 parent fbb3ed3 commit 5af0e5e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

checkswipe.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ function checkswipe(parent, checkbox) {
1414
return
1515
}
1616

17+
if (parent.parentElement?.closest('[data-checkswipe]') || parent.querySelector('[data-checkswipe]')) {
18+
console.error('checkswipe: invalid structure for', parent,'; nested `data-checkswipe` elements are not allowed.')
19+
return
20+
}
21+
1722
if (!(checkbox instanceof HTMLInputElement) || checkbox.type !== 'checkbox') {
1823
console.error('checkswipe: element', checkbox, `must be an html input element (type checkbox); is '${typeof checkbox}'.`)
1924
return
@@ -86,6 +91,11 @@ function checkswipe(parent, checkbox) {
8691
return
8792
}
8893

94+
if (group.parentElement?.closest('[data-checkswipe]') || group.querySelector('[data-checkswipe]')) {
95+
console.error('checkswipe: invalid structure for', group,'; nested `data-checkswipe` elements are not allowed.')
96+
return
97+
}
98+
8999
const hasSpecificCheckbox = group.querySelector('input[type=checkbox][data-checkswipe-use]') !== null
90100
if (hasSpecificCheckbox && group.dataset.checkswipeSpecify === undefined) {
91101
console.error('checkswipe: element', group, 'is missing attribute `data-checkswipe-specify`; has checkboxes with attribute `data-checkswipe-use`. this is not allowed.')

0 commit comments

Comments
 (0)