Skip to content

Commit

Permalink
fix: enable form support for nested input elements (#656)
Browse files Browse the repository at this point in the history
  • Loading branch information
fifoosid committed Jul 23, 2019
1 parent 7548ed0 commit 57adb04
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
14 changes: 8 additions & 6 deletions packages/main/src/features/InputElementsFormSupport.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ class FormSupport {
if (!element.submits) {
return;
}
let parentElement;
do {
parentElement = element.parentElement;
} while (parentElement && parentElement.tagName.toLowerCase() !== "form");
if (parentElement) {
parentElement.submit();
let currentElement = element.parentElement;
while (currentElement && currentElement.tagName.toLowerCase() !== "form") {
currentElement = currentElement.parentElement;
}
if (currentElement) {
currentElement.submit();
} else {
console.error(`${element} is not within a form. Please add it in a form.`); // eslint-disable-line
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@


</body>
</html>
</html>
4 changes: 2 additions & 2 deletions packages/main/test/specs/FormSupport.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ describe("Form support", () => {
submitButton.click();

const formWasSubmitted = browser.execute(() => {
const expectedFormData = "FormSupport.html?input=ok&ta=ok&dp=Apr+10%2C+2019&cb=on&radio=b";
const expectedFormData = "?input=ok&ta=ok&dp=Apr+10%2C+2019&cb=on&radio=b";
return location.href.endsWith(expectedFormData);
});
assert.ok(formWasSubmitted, "For was submitted and URL changed");
});

});
});

0 comments on commit 57adb04

Please sign in to comment.