-
Notifications
You must be signed in to change notification settings - Fork 0
Edge case: orphan button with dynamically removed form #30
Description
Context
This follow-up task was identified during the review of PR #29.
Source PR: #29
PR Title: feat: formless standalone button support
Suggested by: @claude[bot]
Task Description
When a button has form="someForm" and the referenced <form> is later dynamically removed from the DOM, btn.form may return the detached form element (non-null) rather than null. In this case, the orphan button detection (btn.form === null) would NOT treat it as an orphan, even though the form is no longer in the document.
This is an edge case that is unlikely in practice (LiveTemplate re-renders replace the entire wrapper content), but should be documented or tested.
Options
- Add a test demonstrating the behavior and documenting it as expected
- Enhance detection to check
btn.form?.isConnectedin addition to null check
Original Comment
One edge case not tested: a button that becomes an orphan because its associated form was dynamically removed from the DOM. After removal, btn.form can return the detached form element (non-null), so it would NOT be treated as an orphan. Probably fine for the intended use case, but worth noting.
This issue was created from PR review comments.