Kaynağa Gözat

Properly merge values in styles normalizer.

Maciej Gołaszewski 6 yıl önce
ebeveyn
işleme
cfbd5dc5af

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

@@ -7,7 +7,7 @@
  * @module engine/view/styles
  */
 
-import { get, has, isObject, isPlainObject, unset } from 'lodash-es';
+import { get, has, isObject, isPlainObject, merge, unset } from 'lodash-es';
 
 /**
  * Styles class.
@@ -218,7 +218,7 @@ function isLength( string ) {
 
 function addStyle( styleObject, name, value ) {
 	if ( typeof value === 'object' ) {
-		styleObject[ name ] = Object.assign( {}, styleObject[ name ] || {}, value );
+		styleObject[ name ] = merge( {}, styleObject[ name ], value );
 	} else {
 		styleObject[ name ] = value;
 	}

+ 11 - 0
packages/ckeditor5-engine/tests/view/styles.js

@@ -164,6 +164,17 @@ describe( 'Styles', () => {
 						left: { color: 'beige' }
 					} );
 				} );
+
+				it( 'should merge with border shorthand', () => {
+					styleProxy.setStyle( 'border:1px solid blue;border-color:cyan black;' );
+
+					expect( styleProxy.getModel( 'border' ) ).to.deep.equal( {
+						top: { color: 'cyan', style: 'solid', width: '1px' },
+						right: { color: 'black', style: 'solid', width: '1px' },
+						bottom: { color: 'cyan', style: 'solid', width: '1px' },
+						left: { color: 'black', style: 'solid', width: '1px' }
+					} );
+				} );
 			} );
 
 			describe( 'border-style', () => {