Skip to content

Commit 677776d

Browse files
committed
Make the contenteditable check faster
1 parent 5d361fa commit 677776d

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

src/keybinding.tsx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,10 @@ export default function Keybinding(props: KeybindingProps) {
107107
}
108108

109109
/**
110-
* Return true if the current DOM node or one of its parent has the contenteditable
111-
* attribute activated
110+
* Return true if the current DOM node or one of its parents has contenteditable activated
112111
*/
113-
function checkIfContentEditable(node: HTMLElement | null) {
114-
if (node === null) {
115-
return false;
116-
}
117-
118-
if (node.getAttribute('contenteditable') === 'true') {
119-
return true;
120-
}
121-
122-
return checkIfContentEditable(node.parentElement);
112+
function checkIfContentEditable(node: HTMLElement) {
113+
return (
114+
node.closest('[contenteditable]:not([contenteditable="false"])') !== null
115+
);
123116
}

0 commit comments

Comments
 (0)