Phenomenon
When a MutationObserver is attached to a contenteditable element or its parent, the observer callbacks may interfere with editing performance. Frequent DOM mutations during typing can trigger many observer callbacks, causing lag or jank.
Reproduction example
- Create a contenteditable div.
- Attach a MutationObserver that logs all mutations.
- Type text rapidly in the contenteditable.
- Observe performance and any lag.
- Compare with typing without the observer.
Observed behavior
- In Safari on macOS, MutationObserver callbacks can cause performance issues.
- Rapid typing may trigger many mutations and callbacks.
- The UI may lag or become unresponsive.
- Performance degrades with complex observer logic.
Expected behavior
- MutationObserver should not significantly impact editing performance.
- Or, there should be a way to batch mutations.
- Callbacks should be optimized for contenteditable use cases.