diff --git a/modules/dom.js b/modules/dom.js index 26eef94..16a030d 100644 --- a/modules/dom.js +++ b/modules/dom.js @@ -60,8 +60,9 @@ function isButton(el) { } function getSourceContext(el) { - if (el.closest('form')) { - return `form${el.id ? `#${el.id}` : ''}`; + const formEl = el.closest('form'); + if (formEl) { + return `form${formEl.id ? `#${formEl.id}` : ''}`; } const block = el.closest('.block[data-block-name]'); if (block) return `.${block.getAttribute('data-block-name')}`; diff --git a/test/unit/dom.sourceSelector.test.html b/test/unit/dom.sourceSelector.test.html index 6b3ab3e..5c38156 100644 --- a/test/unit/dom.sourceSelector.test.html +++ b/test/unit/dom.sourceSelector.test.html @@ -18,6 +18,9 @@ +