浏览代码

Fixed: Selection#isEqual was throwing in the selection had no ranges.

Szymon Cofalik 9 年之前
父节点
当前提交
b4a9ae0f96
共有 1 个文件被更改,包括 4 次插入2 次删除
  1. 4 2
      packages/ckeditor5-engine/src/model/selection.js

+ 4 - 2
packages/ckeditor5-engine/src/model/selection.js

@@ -132,11 +132,13 @@ export default class Selection {
 	 * @returns {Boolean} `true` if selections are equal, `false` otherwise.
 	 */
 	isEqual( otherSelection ) {
-		if ( !this.anchor.isEqual( otherSelection.anchor ) || !this.focus.isEqual( otherSelection.focus ) ) {
+		if ( this.rangeCount != otherSelection.rangeCount ) {
 			return false;
+		} else if ( this.rangeCount === 0 ) {
+			return true;
 		}
 
-		if ( this.rangeCount != otherSelection.rangeCount ) {
+		if ( !this.anchor.isEqual( otherSelection.anchor ) || !this.focus.isEqual( otherSelection.focus ) ) {
 			return false;
 		}