Skip to content

Deprecate appendChild in favor of append #61778

Closed
@jimmywarting

Description

@jimmywarting

Acknowledgement

  • I acknowledge that issues using this template may be closed without further explanation at the maintainer's discretion.

Comment

Node.append is better than appendChild in most use cases:

  1. Allows appending multiple nodes at once.

  2. Supports both Node and string values.

  3. Reduces boilerplate and repetitive code.

Example:

el.append("Hello", document.createElement("br"), "world");

vs

el.appendChild(document.createTextNode("Hello"));
el.appendChild(document.createElement("br"));
el.appendChild(document.createTextNode("world"));

Proposal:
Mark appendChild as @deprecated in the DOM typings to encourage modern usage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions