add back null check for no form in getRelatedFormData #3394
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The null check in getRelatedFormData was removed recently so it no longer checks if the form is null before returning its internalData. This function can only run on click events for buttons inside forms so this situation should never happen. But it turns out that if during a click event handler you remove the button from the dom then it loses its form and the htmx click handler then throws an exception. The exception doesn't cause any issues its just annoying.
The check was removed because It came up in line of code coverage testing and I was unable to trigger it here. I've now added a simple test that triggers it to maintain 100% code coverage.
Corresponding issue:
#3393
Testing
Added regression test to cover this situation
Checklist
master
for website changes,dev
forsource changes)
approved via an issue
npm run test
) and verified that it succeeded