• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

worktile / slate-angular / 2241d398-cf7c-4f79-b1b3-923ba1e05d17

11 Jul 2025 07:46AM UTC coverage: 48.44%. Remained the same
2241d398-cf7c-4f79-b1b3-923ba1e05d17

push

circleci

pubuzhixing8
build: release 19.1.0-next.3

364 of 925 branches covered (39.35%)

Branch coverage included in aggregate %.

940 of 1767 relevant lines covered (53.2%)

44.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/packages/src/utils/restore-dom.ts
1
import { Editor } from 'slate';
2
import { EDITOR_TO_ELEMENT } from 'slate-dom';
3

4
export function restoreDom(editor: Editor, execute: () => void) {
5
    const editable = EDITOR_TO_ELEMENT.get(editor);
×
6
    let observer = new MutationObserver(mutations => {
×
7
        mutations.reverse().forEach(mutation => {
×
8
            if (mutation.type === 'characterData') {
×
9
                // We don't want to restore the DOM for characterData mutations
10
                // because this interrupts the composition.
11
                return;
×
12
            }
13

14
            mutation.removedNodes.forEach(node => {
×
15
                mutation.target.insertBefore(node, mutation.nextSibling);
×
16
            });
17

18
            mutation.addedNodes.forEach(node => {
×
19
                mutation.target.removeChild(node);
×
20
            });
21
        });
22
        disconnect();
×
23
        execute();
×
24
    });
25
    const disconnect = () => {
×
26
        observer.disconnect();
×
27
        observer = null;
×
28
    };
29
    observer.observe(editable, { subtree: true, childList: true, characterData: true, characterDataOldValue: true });
×
30
    setTimeout(() => {
×
31
        if (observer) {
×
32
            disconnect();
×
33
            execute();
×
34
        }
35
    }, 0);
36
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc