🐛 Guard against null focusNode/anchorNode in text-editor

This commit is contained in:
Andrey Antukh 2026-03-27 07:24:03 +00:00
parent 8db63c9770
commit 3be1ae2ac1

View File

@ -961,7 +961,7 @@ export class SelectionController extends EventTarget {
* @type {boolean} * @type {boolean}
*/ */
get isTextFocus() { get isTextFocus() {
return this.focusNode.nodeType === Node.TEXT_NODE; return this.focusNode != null && this.focusNode.nodeType === Node.TEXT_NODE;
} }
/** /**
@ -970,7 +970,9 @@ export class SelectionController extends EventTarget {
* @type {boolean} * @type {boolean}
*/ */
get isTextAnchor() { get isTextAnchor() {
return this.anchorNode.nodeType === Node.TEXT_NODE; return (
this.anchorNode != null && this.anchorNode.nodeType === Node.TEXT_NODE
);
} }
/** /**