Parcourir la source

Simplified SchemaContext constructor.

Oskar Wróbel il y a 8 ans
Parent
commit
df9400e8cb
1 fichiers modifiés avec 4 ajouts et 9 suppressions
  1. 4 9
      packages/ckeditor5-engine/src/model/schema.js

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

@@ -1074,19 +1074,14 @@ export class SchemaContext {
 			return context;
 			return context;
 		}
 		}
 
 
-		if ( Array.isArray( context ) ) {
-			if ( context[ 0 ] && typeof context[ 0 ] != 'string' && context[ 0 ].is( 'documentFragment' ) ) {
-				context.shift();
-			}
-		}
-		else {
+		if ( !Array.isArray( context ) ) {
 			// `context` is item or position.
 			// `context` is item or position.
 			// Position#getAncestors() doesn't accept any parameters but it works just fine here.
 			// Position#getAncestors() doesn't accept any parameters but it works just fine here.
 			context = context.getAncestors( { includeSelf: true } );
 			context = context.getAncestors( { includeSelf: true } );
+		}
 
 
-			if ( context[ 0 ].is( 'documentFragment' ) ) {
-				context.shift();
-			}
+		if ( context[ 0 ] && typeof context[ 0 ] != 'string' && context[ 0 ].is( 'documentFragment' ) ) {
+			context.shift();
 		}
 		}
 
 
 		this._items = context.map( mapContextItem );
 		this._items = context.map( mapContextItem );