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

worktile / slate-angular / 538f75c8-caf2-4d27-9bda-fd89bebf697f

31 Mar 2025 01:55AM UTC coverage: 46.776%. Remained the same
538f75c8-caf2-4d27-9bda-fd89bebf697f

push

circleci

pubuzhixing8
build: release 19.0.0

409 of 1075 branches covered (38.05%)

Branch coverage included in aggregate %.

1020 of 1980 relevant lines covered (51.52%)

43.99 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 './weak-maps';
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