Skip to content

Commit

Permalink
Remove unnecessary utility function
Browse files Browse the repository at this point in the history
  • Loading branch information
marijnh committed Sep 5, 2024
1 parent 278d8cf commit 6064191
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
6 changes: 0 additions & 6 deletions src/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ export function contains(dom: Node, node: Node | null) {
return node ? dom == node || dom.contains(node.nodeType != 1 ? node.parentNode : node) : false
}

export function deepActiveElement(doc: Document) {
let elt = doc.activeElement
while (elt && elt.shadowRoot) elt = elt.shadowRoot.activeElement
return elt
}

export function hasSelection(dom: HTMLElement, selection: SelectionRange): boolean {
if (!selection.anchorNode) return false
try {
Expand Down
5 changes: 2 additions & 3 deletions src/domobserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import browser from "./browser"
import {ContentView, ViewFlag} from "./contentview"
import {EditorView} from "./editorview"
import {editable, ViewUpdate, setEditContextFormatting, MeasureRequest} from "./extension"
import {hasSelection, getSelection, DOMSelectionState, isEquivalentPosition,
deepActiveElement, dispatchKey, atElementStart} from "./dom"
import {hasSelection, getSelection, DOMSelectionState, isEquivalentPosition, dispatchKey, atElementStart} from "./dom"
import {DOMChange, applyDOMChange, applyDOMChangeInner} from "./domchange"
import type {EditContext} from "./editcontext"
import {Decoration} from "./decoration"
Expand Down Expand Up @@ -201,7 +200,7 @@ export class DOMObserver {
let selection = getSelection(view.root)
if (!selection) return false
let range = browser.safari && (view.root as any).nodeType == 11 &&
deepActiveElement(this.dom.ownerDocument) == this.dom &&
view.root.activeElement == this.dom &&
safariSelectionRangeHack(this.view, selection) || selection
if (!range || this.selectionRange.eq(range)) return false
let local = hasSelection(this.dom, range)
Expand Down

0 comments on commit 6064191

Please sign in to comment.