1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-19 05:31:56 +02:00

Improve performance for Selection.hasEdgeIn methods

This commit is contained in:
Soreine
2016-11-07 18:41:51 +01:00
parent 44180c020e
commit e28b76b709

View File

@@ -190,8 +190,11 @@ class Selection extends new Record(DEFAULTS) {
*/
hasAnchorIn(node) {
const nodes = node.kind == 'text' ? [node] : node.getTexts()
return nodes.some(n => n.key == this.anchorKey)
if (node.kind == 'text') {
return node.key === this.anchorKey
} else {
return node.hasDescendant(this.anchorKey)
}
}
/**
@@ -245,8 +248,11 @@ class Selection extends new Record(DEFAULTS) {
*/
hasFocusIn(node) {
const nodes = node.kind == 'text' ? [node] : node.getTexts()
return nodes.some(n => n.key == this.focusKey)
if (node.kind == 'text') {
return node.key === this.focusKey
} else {
return node.hasDescendant(this.focusKey)
}
}
/**