MutationObserver with subtree:true causes infinite loop when a probe element inside the observed node has its textContent set during the callback
A MutationObserver watching {childList: true, subtree: true} on a container will fire when any descendant's text nodes change. If the observer's callback uses a hidden probe element (appended to the same container) to measure text by setting probe.textContent, that setting creates/replaces text child nodes — which is a childList mutation on a subtree descendant, re-triggering the observer infinitely. Fix: move the probe element outside the observed subtree (e.g. append to document.body instead of the observed node). The probe only needs matching font metrics, not DOM ancestry. Additionally, add a re-entrancy guard (boolean flag) as defense-in-depth against any remaining mutation cycles.