8
0
Просмотр исходного кода

Merge branch 'master' into i/6201

Piotrek Koszuliński 6 лет назад
Родитель
Сommit
602bbfe541

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

@@ -7,7 +7,7 @@
  * @module engine/view/styles/background
  */
 
-import { isAttachment, isColor, isPosition, isRepeat, isURL } from './utils';
+import { getShorthandValues, isAttachment, isColor, isPosition, isRepeat, isURL } from './utils';
 
 /**
  * Adds a background CSS styles processing rules.
@@ -46,7 +46,7 @@ export function addBackgroundRules( stylesProcessor ) {
 function normalizeBackground( value ) {
 	const background = {};
 
-	const parts = value.split( ' ' );
+	const parts = getShorthandValues( value );
 
 	for ( const part of parts ) {
 		if ( isRepeat( part ) ) {

+ 27 - 2
packages/ckeditor5-engine/tests/view/styles/background.js

@@ -20,7 +20,6 @@ describe( 'Background styles normalization', () => {
 	} );
 
 	it( 'should normalize background', () => {
-		// TODO: border-box given only for coverage test.
 		styles.setTo( 'background:url("example.jpg") center #f00 repeat-y fixed border-box;' );
 
 		expect( styles.getNormalized( 'background' ) ).to.deep.equal( {
@@ -32,7 +31,27 @@ describe( 'Background styles normalization', () => {
 		} );
 	} );
 
-	// TODO: define what should happen with layers
+	it( 'should normalize background (color with spaces)', () => {
+		styles.setTo( 'background:url("example.jpg") center rgb(253, 253, 119) repeat-y fixed border-box;' );
+
+		expect( styles.getNormalized( 'background' ) ).to.deep.equal( {
+			attachment: 'fixed',
+			image: 'url("example.jpg")',
+			position: [ 'center' ],
+			repeat: [ 'repeat-y' ],
+			color: 'rgb(253, 253, 119)'
+		} );
+	} );
+
+	it( 'should normalize background (color only with spaces)', () => {
+		styles.setTo( 'background: rgb(253, 253, 119);' );
+
+		expect( styles.getNormalized( 'background' ) ).to.deep.equal( {
+			color: 'rgb(253, 253, 119)'
+		} );
+	} );
+
+	// Layers are not supported.
 	it.skip( 'should normalize background with layers', () => {
 		styles.setTo( 'background:url("test.jpg") repeat-y,#f00;' );
 
@@ -45,6 +64,12 @@ describe( 'Background styles normalization', () => {
 		expect( styles.getNormalized( 'background' ) ).to.deep.equal( { color: '#f00' } );
 	} );
 
+	it( 'should normalize background-color with rgb() value', () => {
+		styles.setTo( 'background-color:rgba(253, 253, 119, 1);' );
+
+		expect( styles.getNormalized( 'background' ) ).to.deep.equal( { color: 'rgba(253, 253, 119, 1)' } );
+	} );
+
 	it( 'should output inline background-color style', () => {
 		styles.setTo( 'background:#f00;' );