Skip to content

Edge case: orphan button with dynamically removed form #30

@adnaan

Description

@adnaan

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

  1. Add a test demonstrating the behavior and documenting it as expected
  2. Enhance detection to check btn.form?.isConnected in 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    follow-upFollow-up task from PR review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions