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
{{ message }}
Repository navigation
[lit-html] removePart() leaks end marker comment, causing unbounded DOM accumulation under sustained churn #5298
removePart() in lit-html/directive-helpers.js only removes the part's start marker, leaving the end marker (<!---->) orphaned in the DOM. Parts created via insertPart() own two unique marker comments, and both must be removed.
Each call leaks one <!----> comment node. Under sustained churn, these accumulate without bound — a visible effect is @lit-labs/virtualizer scrolling, where items are continuously removed at one edge and added at the other. As the container fills with orphan comment nodes, per-operation cost (e.g. subsequent node.remove() calls) climbs steadily, causing observable scroll performance degradation over time.
The regression was introduced in #4975 ("Remove some redundant code from removePart()") and shipped in [email protected]. Prior to that PR, removePart walked sibling nodes up to (and including) the end marker, correctly removing both markers.
The existing test 'removePart removes the start marker' (added alongside #4975) does not catch this because it uses a directive at the end of a <div>, where the part's _$endNode is null. The bug only manifests when _$endNode is a real marker node, which is the case for parts created via insertPart().
Reproduction
Local tachometer measurements against lit-html/repeat (15 samples, Chromium, local build, A/B vs. patched build):
lit-html/repeat update: 595.28 ms → 63.08 ms (−89.4%)
lit-html/repeat-full remove: 54.90 ms → 0.23 ms (−99.6%)
A minimal programmatic repro (regression test) uses insertPart() to create a ChildPart with a non-null _$endNode, calls removePart(), and observes that the container's childNodes.length only drops by 1 instead of 2.
Workaround
I have not found a workaround at the application level. Downgrading to [email protected] avoids the regression.
Activity
Check that a page at rest, a closed surface and a resize leave the pa…
build: Gyral 0.2.0, lit-html pinned to 3.3.0 (shop-1tc)