Explorar el Código

Reducer should only work on value.

Maciej Gołaszewski hace 6 años
padre
commit
b2588b986c

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

@@ -266,14 +266,10 @@ export class StylesProcessor {
 	 * @returns {module:engine/view/styles~PropertyEntry}
 	 */
 	getReducedForm( styleName, normalizedValue ) {
-		const data = {
-			value: normalizedValue
-		};
-
 		if ( this._reducers.has( styleName ) ) {
 			const reducer = this._reducers.get( styleName );
 
-			return reducer( data );
+			return reducer( normalizedValue );
 		}
 
 		return [ [ styleName, normalizedValue ] ];

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

@@ -12,10 +12,10 @@ import { isAttachment, isColor, isPosition, isRepeat, isURL } from './utils';
 export function addBackgroundStylesProcessor( stylesProcessor ) {
 	stylesProcessor.setNormalizer( 'background', normalizeBackground );
 	stylesProcessor.setNormalizer( 'background-color', value => ( { path: 'background.color', value } ) );
-	stylesProcessor.setReducer( 'background', data => {
+	stylesProcessor.setReducer( 'background', value => {
 		const ret = [];
 
-		ret.push( [ 'background-color', data.value.color ] );
+		ret.push( [ 'background-color', value.color ] );
 
 		return ret;
 	} );

+ 6 - 6
packages/ckeditor5-engine/src/view/styles/borderstyles.js

@@ -180,19 +180,19 @@ function normalizeBorderShorthand( string ) {
 	return result;
 }
 
-function borderReducer( data ) {
+function borderReducer( value ) {
 	const reduced = [];
 
-	reduced.push( ...reduceBorderPosition( extractBorderPosition( data.value, 'top' ), 'top' ) );
-	reduced.push( ...reduceBorderPosition( extractBorderPosition( data.value, 'right' ), 'right' ) );
-	reduced.push( ...reduceBorderPosition( extractBorderPosition( data.value, 'bottom' ), 'bottom' ) );
-	reduced.push( ...reduceBorderPosition( extractBorderPosition( data.value, 'left' ), 'left' ) );
+	reduced.push( ...reduceBorderPosition( extractBorderPosition( value, 'top' ), 'top' ) );
+	reduced.push( ...reduceBorderPosition( extractBorderPosition( value, 'right' ), 'right' ) );
+	reduced.push( ...reduceBorderPosition( extractBorderPosition( value, 'bottom' ), 'bottom' ) );
+	reduced.push( ...reduceBorderPosition( extractBorderPosition( value, 'left' ), 'left' ) );
 
 	return reduced;
 }
 
 function getBorderPositionReducer( which ) {
-	return data => ( data.reduced = reduceBorderPosition( data.value, which ) );
+	return value => reduceBorderPosition( value, which );
 }
 
 function reduceBorderPosition( value, which ) {

+ 3 - 3
packages/ckeditor5-engine/src/view/styles/utils.js

@@ -65,8 +65,8 @@ export function getTopRightBottomLeftValues( value = '' ) {
 }
 
 export function getTopRightBottomLeftValueReducer( styleShorthand ) {
-	return data => {
-		const { top, right, bottom, left } = ( data.value || {} );
+	return value => {
+		const { top, right, bottom, left } = ( value || {} );
 
 		const reduced = [];
 
@@ -87,7 +87,7 @@ export function getTopRightBottomLeftValueReducer( styleShorthand ) {
 				reduced.push( [ styleShorthand + '-left', left ] );
 			}
 		} else {
-			reduced.push( [ styleShorthand, getTopRightBottomLeftShorthandValue( data.value ) ] );
+			reduced.push( [ styleShorthand, getTopRightBottomLeftShorthandValue( value ) ] );
 		}
 
 		return reduced;