8
0
Просмотр исходного кода

Changed Schema#findAllowedParent() limitChecker to limitElement.

Oskar Wróbel 8 лет назад
Родитель
Сommit
9791c28fc6

+ 3 - 4
packages/ckeditor5-engine/src/model/schema.js

@@ -681,11 +681,10 @@ export default class Schema {
 	 *
 	 * @params {module:engine/model/node~Node} node Node for which allowed parent should be found.
 	 * @params {module:engine/model/position~Position} position Position from searching will start.
-	 * @params {Function<module:engine/model/element~Element>} [limitChecker] When function is defined and returns true
-	 * then stops searching and returns null as a search result. Function gets current parent as a parameter.
+	 * @params {module:engine/model/element~Element} [limitElement] Custom limit element.
 	 * @returns {module:engine/model/element~Element|null} element Allowed parent or null if nothing was found.
 	 */
-	findAllowedParent( node, position, limitChecker ) {
+	findAllowedParent( node, position, limitElement ) {
 		let parent = position.parent;
 
 		while ( parent ) {
@@ -697,7 +696,7 @@ export default class Schema {
 				return null;
 			}
 
-			if ( typeof limitChecker == 'function' && limitChecker( parent ) ) {
+			if ( parent === limitElement ) {
 				return null;
 			}
 

+ 2 - 2
packages/ckeditor5-engine/tests/model/schema.js

@@ -1189,7 +1189,7 @@ describe( 'Schema', () => {
 			expect( parent ).to.null;
 		} );
 
-		it( 'should use custom limit checker nad return null if returns true', () => {
+		it( 'should use custom limit element nad return null if is reached', () => {
 			// $root is allowed ancestor for blockQuote.
 			const node = new Element( 'blockQuote' );
 
@@ -1197,7 +1197,7 @@ describe( 'Schema', () => {
 				node,
 				Position.createAt( r1bQp ),
 				// However lest stop searching when blockQuote is reached.
-				element => element.name == 'blockQuote'
+				r1bQ
 			);
 
 			expect( parent ).to.null;