mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-20 06:01:24 +02:00
Improve performance for Selection.hasEdgeIn methods
This commit is contained in:
@@ -190,8 +190,11 @@ class Selection extends new Record(DEFAULTS) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
hasAnchorIn(node) {
|
hasAnchorIn(node) {
|
||||||
const nodes = node.kind == 'text' ? [node] : node.getTexts()
|
if (node.kind == 'text') {
|
||||||
return nodes.some(n => n.key == this.anchorKey)
|
return node.key === this.anchorKey
|
||||||
|
} else {
|
||||||
|
return node.hasDescendant(this.anchorKey)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -245,8 +248,11 @@ class Selection extends new Record(DEFAULTS) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
hasFocusIn(node) {
|
hasFocusIn(node) {
|
||||||
const nodes = node.kind == 'text' ? [node] : node.getTexts()
|
if (node.kind == 'text') {
|
||||||
return nodes.some(n => n.key == this.focusKey)
|
return node.key === this.focusKey
|
||||||
|
} else {
|
||||||
|
return node.hasDescendant(this.focusKey)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user