diff --git a/checkswipe.js b/checkswipe.js index f45010f..87152b2 100644 --- a/checkswipe.js +++ b/checkswipe.js @@ -14,6 +14,11 @@ function checkswipe(parent, checkbox) { return } + if (parent.parentElement?.closest('[data-checkswipe]') || parent.querySelector('[data-checkswipe]')) { + console.error('checkswipe: invalid structure for', parent,'; nested `data-checkswipe` elements are not allowed.') + return + } + if (!(checkbox instanceof HTMLInputElement) || checkbox.type !== 'checkbox') { console.error('checkswipe: element', checkbox, `must be an html input element (type checkbox); is '${typeof checkbox}'.`) return @@ -86,6 +91,11 @@ function checkswipe(parent, checkbox) { return } + if (group.parentElement?.closest('[data-checkswipe]') || group.querySelector('[data-checkswipe]')) { + console.error('checkswipe: invalid structure for', group,'; nested `data-checkswipe` elements are not allowed.') + return + } + const hasSpecificCheckbox = group.querySelector('input[type=checkbox][data-checkswipe-use]') !== null if (hasSpecificCheckbox && group.dataset.checkswipeSpecify === undefined) { console.error('checkswipe: element', group, 'is missing attribute `data-checkswipe-specify`; has checkboxes with attribute `data-checkswipe-use`. this is not allowed.')