Procházet zdrojové kódy

Improve name of variables used in code.

Mateusz Samsel před 6 roky
rodič
revize
7db230a967

+ 6 - 7
packages/ckeditor5-enter/src/entercommand.js

@@ -56,10 +56,9 @@ function enterBlock( model, writer, selection, schema ) {
 	}
 
 	if ( isSelectionEmpty ) {
-		// List of text attributes copied to new line/block.
-		const filteredAttr = getAllowedAttributes( writer.model.schema, selection.getAttributes() );
+		const attributesToCopy = getCopyOnEnterAttributes( writer.model.schema, selection.getAttributes() );
 		splitBlock( writer, range.start );
-		writer.setSelectionAttribute( filteredAttr );
+		writer.setSelectionAttribute( attributesToCopy );
 	} else {
 		const leaveUnmerged = !( range.start.isAtStart && range.end.isAtEnd );
 		const isContainedWithinOneElement = ( startElement == endElement );
@@ -88,10 +87,10 @@ function splitBlock( writer, splitPos ) {
 	writer.setSelection( splitPos.parent.nextSibling, 0 );
 }
 
-function* getAllowedAttributes( schema, allAttributes ) {
-	for ( const attr of allAttributes ) {
-		if ( attr && schema.getAttributeProperties( attr[ 0 ] ).copyOnEnter ) {
-			yield attr;
+function* getCopyOnEnterAttributes( schema, allAttributes ) {
+	for ( const attribute of allAttributes ) {
+		if ( attribute && schema.getAttributeProperties( attribute[ 0 ] ).copyOnEnter ) {
+			yield attribute;
 		}
 	}
 }

+ 1 - 1
packages/ckeditor5-enter/tests/entercommand.js

@@ -90,7 +90,7 @@ describe( 'EnterCommand', () => {
 
 			describe( 'copyOnEnter', () => {
 				beforeEach( () => {
-					schema.extend( '$text', { allowAttributes: 'foo' } );
+					schema.extend( '$text', { allowAttributes: [ 'foo', 'bar' ] } );
 					schema.setAttributeProperties( 'foo', { copyOnEnter: true } );
 				} );