children vs childNodes

children only contains element nodes.

childNodes contains all node types including: text nodes, whitespace, comments, and elements.

This difference becomes important when reusing or enhancing existing DOM structures.

Important

DOMPP intentionally exposes both children and childNodes during callback mutations.

This allows developers to choose between: Enhancement and hydration-like flows often require access to childNodes instead of only elements.

Reuse Pattern

tree

  .setChildren(
    ({ children }) => [

      ...children

    ]
  );

// text nodes disappear

tree

  .setChildren(
    ({ childNodes }) => [

      ...childNodes

    ]
  );

// all nodes preserved
Notes
  • children excludes text nodes
  • childNodes preserves exact DOM structure
  • DOMPP exposes both APIs intentionally for reuse and enhancement flows

Live Preview