Explorar o código

Changed: simplified implementation of model/view.Selection#isEqual.

Szymon Cofalik %!s(int64=9) %!d(string=hai) anos
pai
achega
e67d311925

+ 16 - 8
packages/ckeditor5-engine/src/model/selection.js

@@ -142,14 +142,22 @@ export default class Selection {
 			return false;
 		}
 
-		// Every range from this selection...
-		return Array.from( this.getRanges() ).every( ( rangeA ) => {
-			// ... has a range in other selection...
-			return Array.from( otherSelection.getRanges() ).some( ( rangeB ) => {
-				// ... which it is equal to.
-				return rangeA.isEqual( rangeB );
-			} );
-		} );
+		for ( let thisRange of this._ranges ) {
+			let found = false;
+
+			for ( let otherRange of otherSelection._ranges ) {
+				if ( thisRange.isEqual( otherRange ) ) {
+					found = true;
+					break;
+				}
+			}
+
+			if ( !found ) {
+				return false;
+			}
+		}
+
+		return true;
 	}
 
 	/**

+ 16 - 8
packages/ckeditor5-engine/src/view/selection.js

@@ -308,14 +308,22 @@ export default class Selection {
 			return false;
 		}
 
-		// Every range from this selection...
-		return Array.from( this.getRanges() ).every( ( rangeA ) => {
-			// ... has a range in other selection...
-			return Array.from( otherSelection.getRanges() ).some( ( rangeB ) => {
-				// ... which it is equal to.
-				return rangeA.isEqual( rangeB );
-			} );
-		} );
+		for ( let thisRange of this._ranges ) {
+			let found = false;
+
+			for ( let otherRange of otherSelection._ranges ) {
+				if ( thisRange.isEqual( otherRange ) ) {
+					found = true;
+					break;
+				}
+			}
+
+			if ( !found ) {
+				return false;
+			}
+		}
+
+		return true;
 	}
 
 	/**