You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implements the
[`ParentNode.children`](https://dom.spec.whatwg.org/#dom-parentnode-children)
getter on `Element`, `Document`, and `DocumentFragment`.
Returns a `LiveNodeList` of direct element children, filtering out text,
comment, processing instruction, and other non-element nodes.
### Approach
Uses `Object.defineProperty` getters backed by `LiveNodeList` — no extra
state is maintained on the node. This follows the getter/setter approach
[discussed in
#652](#652 (comment)):
> *"with the amount of state maintenance in this lib I'm leaning towards
doing as many things as possible using a getter/setter approach"*
The getter computes from `firstChild`/`nextSibling` on access.
`LiveNodeList` handles cache invalidation automatically via the `_inc`
counter on DOM mutations.
### Deviation from spec
The DOM spec marks `.children` with
[`[SameObject]`](https://webidl.spec.whatwg.org/#SameObject) (same
reference on each access). This implementation returns a new
`LiveNodeList` per access, matching the existing `getElementsByTagName`
pattern. Caching per-node was avoided to keep zero extra state on nodes,
consistent with the getter/setter preference above.
Fixes#410
0 commit comments