Selaa lähdekoodia

Remove sorting from Styles._getStylesEntries().

Maciej Gołaszewski 6 vuotta sitten
vanhempi
sitoutus
3e783b0058

+ 5 - 2
packages/ckeditor5-engine/src/view/styles.js

@@ -177,7 +177,10 @@ export default class Styles {
 			return;
 		}
 
-		return entries.map( arr => arr.join( ':' ) ).join( ';' ) + ';';
+		return entries
+			.map( arr => arr.join( ':' ) )
+			.sort()
+			.join( ';' ) + ';';
 	}
 
 	/**
@@ -235,7 +238,7 @@ export default class Styles {
 	_getStylesEntries() {
 		const parsed = [];
 
-		const keys = Object.keys( this._styles ).sort();
+		const keys = Object.keys( this._styles );
 
 		for ( const key of keys ) {
 			const normalized = this.styleProcessor.getNormalized( key, this._styles );

+ 1 - 1
packages/ckeditor5-engine/tests/view/styles.js

@@ -232,7 +232,7 @@ describe( 'Styles', () => {
 		it( 'should output custom style names', () => {
 			styles.setStyle( 'foo: 2;bar: baz;foo-bar-baz:none;' );
 
-			expect( styles.getStyleNames() ).to.deep.equal( [ 'bar', 'foo', 'foo-bar-baz' ] );
+			expect( styles.getStyleNames() ).to.deep.equal( [ 'foo', 'bar', 'foo-bar-baz' ] );
 		} );
 
 		it( 'should output full names for known style names', () => {

+ 38 - 8
packages/ckeditor5-engine/tests/view/styles/borderstyles.js

@@ -63,7 +63,10 @@ describe( 'Border styles normalization', () => {
 		styles.setStyle( 'border:1px solid blue;' );
 
 		expect( styles.getInlineStyle() ).to.equal(
-			'border-top:1px solid blue;border-right:1px solid blue;border-bottom:1px solid blue;border-left:1px solid blue;'
+			'border-bottom:1px solid blue;' +
+			'border-left:1px solid blue;' +
+			'border-right:1px solid blue;' +
+			'border-top:1px solid blue;'
 		);
 		expect( styles.getInlineProperty( 'border-color' ) ).to.equal( 'blue' );
 		expect( styles.getInlineProperty( 'border-style' ) ).to.equal( 'solid' );
@@ -86,7 +89,10 @@ describe( 'Border styles normalization', () => {
 		styles.setStyle( 'border:1px solid blue;border-left:#665511 dashed 2.7em;border-top:7px dotted #ccc;' );
 
 		expect( styles.getInlineStyle() ).to.equal(
-			'border-top:7px dotted #ccc;border-right:1px solid blue;border-bottom:1px solid blue;border-left:2.7em dashed #665511;'
+			'border-bottom:1px solid blue;' +
+			'border-left:2.7em dashed #665511;' +
+			'border-right:1px solid blue;' +
+			'border-top:7px dotted #ccc;'
 		);
 
 		expect( styles.getInlineProperty( 'border' ) ).to.be.undefined;
@@ -131,7 +137,10 @@ describe( 'Border styles normalization', () => {
 		styles.insertProperty( 'border-top', '7px dotted #ccc' );
 
 		expect( styles.getInlineStyle() ).to.equal(
-			'border-top:7px dotted #ccc;border-right:1px solid blue;border-bottom:1px solid blue;border-left:2.7em dashed #665511;'
+			'border-bottom:1px solid blue;' +
+			'border-left:2.7em dashed #665511;' +
+			'border-right:1px solid blue;' +
+			'border-top:7px dotted #ccc;'
 		);
 		expect( styles.getInlineProperty( 'border' ) ).to.be.undefined;
 		expect( styles.getInlineProperty( 'border-color' ) ).to.equal( '#ccc blue blue #665511' );
@@ -144,7 +153,10 @@ describe( 'Border styles normalization', () => {
 		styles.removeProperty( 'border-color' );
 
 		expect( styles.getInlineStyle() ).to.equal(
-			'border-top:1px solid;border-right:1px solid;border-bottom:1px solid;border-left:1px solid;'
+			'border-bottom:1px solid;' +
+			'border-left:1px solid;' +
+			'border-right:1px solid;' +
+			'border-top:1px solid;'
 		);
 
 		expect( styles.getInlineProperty( 'border' ) ).to.be.undefined;
@@ -160,7 +172,12 @@ describe( 'Border styles normalization', () => {
 	it( 'should output border with only style shorthand (style)', () => {
 		styles.setStyle( 'border:solid;' );
 
-		expect( styles.getInlineStyle() ).to.equal( 'border-top:solid;border-right:solid;border-bottom:solid;border-left:solid;' );
+		expect( styles.getInlineStyle() ).to.equal(
+			'border-bottom:solid;' +
+			'border-left:solid;' +
+			'border-right:solid;' +
+			'border-top:solid;'
+		);
 		expect( styles.getInlineProperty( 'border' ) ).to.be.undefined;
 		expect( styles.getInlineProperty( 'border-color' ) ).to.be.undefined;
 		expect( styles.getInlineProperty( 'border-style' ) ).to.equal( 'solid' );
@@ -174,7 +191,12 @@ describe( 'Border styles normalization', () => {
 	it( 'should output border with only style shorthand (color)', () => {
 		styles.setStyle( 'border:#f00;' );
 
-		expect( styles.getInlineStyle() ).to.equal( 'border-top:#f00;border-right:#f00;border-bottom:#f00;border-left:#f00;' );
+		expect( styles.getInlineStyle() ).to.equal(
+			'border-bottom:#f00;' +
+			'border-left:#f00;' +
+			'border-right:#f00;' +
+			'border-top:#f00;'
+		);
 		expect( styles.getInlineProperty( 'border' ) ).to.be.undefined;
 		expect( styles.getInlineProperty( 'border-color' ) ).to.equal( '#f00' );
 		expect( styles.getInlineProperty( 'border-style' ) ).to.be.undefined;
@@ -188,7 +210,12 @@ describe( 'Border styles normalization', () => {
 	it( 'should output border with only style shorthand (width)', () => {
 		styles.setStyle( 'border:1px;' );
 
-		expect( styles.getInlineStyle() ).to.equal( 'border-top:1px;border-right:1px;border-bottom:1px;border-left:1px;' );
+		expect( styles.getInlineStyle() ).to.equal(
+			'border-bottom:1px;' +
+			'border-left:1px;' +
+			'border-right:1px;' +
+			'border-top:1px;'
+		);
 		expect( styles.getInlineProperty( 'border' ) ).to.be.undefined;
 		expect( styles.getInlineProperty( 'border-color' ) ).to.be.undefined;
 		expect( styles.getInlineProperty( 'border-style' ) ).to.be.undefined;
@@ -565,7 +592,10 @@ describe( 'Border styles normalization', () => {
 			);
 
 			expect( styles.getInlineStyle() ).to.equal(
-				'border-top:none;border-right:3.0pt dotted #FFC000;border-bottom:3.0pt dotted #FFC000;border-left:none;'
+				'border-bottom:3.0pt dotted #FFC000;' +
+				'border-left:none;' +
+				'border-right:3.0pt dotted #FFC000;' +
+				'border-top:none;'
 			);
 			expect( styles.getInlineProperty( 'border-top' ) ).to.equal( 'none' );
 			expect( styles.getInlineProperty( 'border-right' ) ).to.equal( '3.0pt dotted #FFC000' );