From f65b4eae277e3790efb640dff20ceab69ca643e5 Mon Sep 17 00:00:00 2001 From: vdua Date: Mon, 21 Oct 2024 14:51:09 +0530 Subject: [PATCH 1/2] bug: form id is not getting sent correctly in source selector - adding a failing test case --- test/unit/dom.sourceSelector.test.html | 4 ++++ 1 file changed, 4 insertions(+) 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 @@ +
+ +
@@ -53,6 +56,7 @@ expect(sourceSelector(document.querySelector('input[type="checkbox"'))).to.be.equal('form#a-form input[type=\'checkbox\'].a-checkbox'); expect(sourceSelector(document.querySelector('input.a-none'))).to.be.equal('form#a-form input[type=\'\'].a-none'); expect(sourceSelector(document.querySelector('textarea'))).to.be.equal('form#a-form textarea.a-textarea'); + expect(sourceSelector(document.querySelector('input.a-text-inside-div'))).to.be.equal('form#a-form input[type=\'text\'].a-text-inside-div'); expect(sourceSelector(document.querySelector('.a-block'))).to.be.equal('.a-block'); expect(sourceSelector(document.querySelector('#a-div-in-block'))).to.be.equal('.a-block #a-div-in-block'); From 9d21c60322199de0742b0dba9f0e8fc5b19e6f83 Mon Sep 17 00:00:00 2001 From: vdua Date: Mon, 21 Oct 2024 15:26:16 +0530 Subject: [PATCH 2/2] bug: form id is not getting sent correctly in source selector - when the parent element has an id, that id was being sent instead of the id of the form element --- modules/dom.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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')}`;