Procházet zdrojové kódy

Removed checking selection direction.

Oskar Wróbel před 7 roky
rodič
revize
2177fe5619

+ 2 - 8
packages/ckeditor5-basic-styles/src/attributecommand.js

@@ -127,14 +127,8 @@ export default class AttributeCommand extends Command {
 			return selection.hasAttribute( this.attributeKey );
 		}
 
-		const ranges = Array.from( selection.getRanges() );
-
-		if ( selection.isBackward ) {
-			ranges.reverse();
-		}
-
-		for ( const range of ranges ) {
-			for ( const item of range.getItems( { direction: selection.isBackward ? 'backward' : 'forward' } ) ) {
+		for ( const range of selection.getRanges() ) {
+			for ( const item of range.getItems() ) {
 				if ( schema.checkAttribute( item, this.attributeKey ) ) {
 					return item.hasAttribute( this.attributeKey );
 				}

+ 4 - 28
packages/ckeditor5-basic-styles/tests/attributecommand.js

@@ -69,54 +69,30 @@ describe( 'AttributeCommand', () => {
 			expect( command.value ).to.be.false;
 		} );
 
-		it( 'is true when the first item that allows attribute has the attribute set - forward #1', () => {
+		it( 'is true when the first item that allows attribute has the attribute set #1', () => {
 			setData( model, '<p><$text bold="true">fo[o</$text></p><h1>b]ar</h1>' );
 
 			expect( command.value ).to.be.true;
 		} );
 
-		it( 'is true when the first item that allows attribute has the attribute set - forward #2', () => {
+		it( 'is true when the first item that allows attribute has the attribute set #2', () => {
 			setData( model, '<h1>fo[o</h1><p><$text bold="true">f</$text>o]o</p>' );
 
 			expect( command.value ).to.be.true;
 		} );
 
-		it( 'is false when the first item that allows attribute has not the attribute set - forward #1', () => {
+		it( 'is false when the first item that allows attribute has not the attribute set #1', () => {
 			setData( model, '<p>b[a<$text bold="true">r</$text></p><h1>fo]o</h1>' );
 
 			expect( command.value ).to.be.false;
 		} );
 
-		it( 'is false when the first item that allows attribute has not the attribute set - forward #2', () => {
+		it( 'is false when the first item that allows attribute has not the attribute set #2', () => {
 			setData( model, '<h1>fo[o</h1><p>b<$text bold="true">r</$text>r]</p>' );
 
 			expect( command.value ).to.be.false;
 		} );
 
-		it( 'is true when the first item that allows attribute has the attribute set - backward #1', () => {
-			setData( model, '<h1>fo[o</h1><p>b<$text bold="true">ar]</$text></p>', { lastRangeBackward: true } );
-
-			expect( command.value ).to.be.true;
-		} );
-
-		it( 'is true when the first item that allows attribute has the attribute set - backward #2', () => {
-			setData( model, '<p>b[a<$text bold="true">r</$text></p><h1>fo]o</h1>', { lastRangeBackward: true } );
-
-			expect( command.value ).to.be.true;
-		} );
-
-		it( 'is false when the first item that allows attribute has not the attribute set - backward #1', () => {
-			setData( model, '<h1>fo[o</h1><p>b<$text bold="true">a</$text>r]</p>', { lastRangeBackward: true } );
-
-			expect( command.value ).to.be.false;
-		} );
-
-		it( 'is false when the first item that allows attribute has not the attribute set - backward #2', () => {
-			setData( model, '<p>f[<$text bold="true">o</$text>o</p><h1>ba]r</h1>', { lastRangeBackward: true } );
-
-			expect( command.value ).to.be.false;
-		} );
-
 		it( 'is true when the first item that allows attribute has the attribute set - object with nested editable', () => {
 			model.schema.register( 'caption', {
 				allowContentOf: '$block',