Переглянути джерело

Add tests for parsing top right bottom left empty value.

Maciej Gołaszewski 6 роки тому
батько
коміт
b8ae9f413c

+ 0 - 1
packages/ckeditor5-engine/src/view/element.js

@@ -613,7 +613,6 @@ export default class Element extends Node {
 		if ( key == 'class' ) {
 			parseClasses( this._classes, value );
 		} else if ( key == 'style' ) {
-			// parseInlineStyles( this._styles, value );
 			this._styles.setStyle( value );
 		} else {
 			this._attrs.set( key, value );

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

@@ -380,7 +380,11 @@ export default class Styles {
 	}
 }
 
-function getTopRightBottomLeftValues( value ) {
+function getTopRightBottomLeftValues( value = '' ) {
+	if ( value === '' ) {
+		return { top: undefined, right: undefined, bottom: undefined, left: undefined };
+	}
+
 	const values = value.split( ' ' );
 
 	const top = values[ 0 ];

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

@@ -237,6 +237,16 @@ describe( 'Styles', () => {
 				} );
 			} );
 
+			it( 'should parse border shorthand with only style', () => {
+				styles.setStyle( 'border:solid;' );
+
+				expect( styles.getNormalized( 'border' ) ).to.deep.equal( {
+					color: { top: undefined, right: undefined, bottom: undefined, left: undefined },
+					style: { top: 'solid', right: 'solid', bottom: 'solid', left: 'solid' },
+					width: { top: undefined, right: undefined, bottom: undefined, left: undefined }
+				} );
+			} );
+
 			it( 'should parse border shorthand with other shorthands', () => {
 				styles.setStyle( 'border:1px solid blue;border-left:#665511 dashed 2.7em;border-top:7px dotted #ccc;' );
 
@@ -327,6 +337,12 @@ describe( 'Styles', () => {
 				expect( styles.getInlineProperty( 'border-width' ) ).to.equal( '1px' );
 			} );
 
+			it( 'should output border with only style shorthand', () => {
+				styles.setStyle( 'border:solid;' );
+
+				expect( styles.getInlineStyle() ).to.equal( 'border-style:solid;' );
+			} );
+
 			describe( 'border-color', () => {
 				it( 'should set all border colors (1 value defined)', () => {
 					styles.setStyle( 'border-color:cyan;' );