瀏覽代碼

Rename StylesMap.getInlineProperty() to getAsString() and improve docs.

Maciej Gołaszewski 5 年之前
父節點
當前提交
6e4d24d0fc

+ 22 - 2
packages/ckeditor5-engine/src/view/element.js

@@ -339,7 +339,7 @@ export default class Element extends Node {
 		for ( const property of this._styles.getStyleNames() ) {
 			if (
 				!otherElement._styles.has( property ) ||
-				otherElement._styles.getInlineProperty( property ) !== this._styles.getInlineProperty( property )
+				otherElement._styles.getAsString( property ) !== this._styles.getAsString( property )
 			) {
 				return false;
 			}
@@ -380,11 +380,31 @@ export default class Element extends Node {
 	 * Returns style value for given property.
 	 * Undefined is returned if style does not exist.
 	 *
+	 * *Note*: This method will only return normalized styles if a style processor was defined. Otherwise the style names are not
+	 * normalized.
+	 *
+	 * For an element with style set to: 'margin:1px
+	 *
+	 *		// Enable 'margin' shorthand processing:
+	 *		editor.editing.view.document.addStyleProcessorRules( addMarginStylesProcessor );
+	 *
+	 *		const element = view.change( writer => {
+	 *			const element = writer.createElement();
+	 *			writer.setStyle( 'margin', '1px' )
+	 *			writer.setStyle( 'margin-bottom', '3em' )
+	 *
+	 *			return element;
+	 *		} );
+	 *
+	 *		element.getStyle( 'margin' );
+	 *
+	 *		// will return 'margin: 1px 1px 3em;'
+	 *
 	 * @param {String} property
 	 * @returns {String|undefined}
 	 */
 	getStyle( property ) {
-		return this._styles.getInlineProperty( property );
+		return this._styles.has( property ) ? this._styles.getAsString( property ) : undefined;
 	}
 
 	/**

+ 18 - 3
packages/ckeditor5-engine/src/view/stylesmap.js

@@ -211,6 +211,9 @@ export default class StylesMap {
 	/**
 	 * Returns a normalized style object or a single value.
 	 *
+	 *		// Enable 'margin' shorthand processing:
+	 *		editor.editing.view.document.addStyleProcessorRules( addMarginStylesProcessor );
+	 *
 	 *		const styles = new Styles();
 	 *		styles.setTo( 'margin:1px 2px 3em;' );
 	 *
@@ -270,14 +273,26 @@ export default class StylesMap {
 	}
 
 	/**
-	 * Returns property value string.
+	 * Returns property as a value string.
+	 *
+	 *		// Enable 'margin' shorthand processing:
+	 *		editor.editing.view.document.addStyleProcessorRules( addMarginStylesProcessor );
+	 *
+	 *		const styles = new Styles();
+	 *		styles.setTo( 'margin:1px;' );
+	 *		styles.set( 'margin-bottom:3em;' );
+	 *
+	 *		styles.getAsString( 'margin' );
+	 *		// will return 'margin: 1px 1px 3em;'
+	 *
+	 * *Note*: To get normalized version of a longhand property use {@link #getNormalized} method.
 	 *
 	 * @param {String} propertyName
 	 * @returns {String|undefined}
 	 */
-	getInlineProperty( propertyName ) {
+	getAsString( propertyName ) {
 		if ( this.isEmpty ) {
-			return;
+			return '';
 		}
 
 		const normalized = this._styleProcessor.getNormalized( propertyName, this._styles );

+ 5 - 5
packages/ckeditor5-engine/tests/view/element.js

@@ -73,11 +73,11 @@ describe( 'Element', () => {
 			expect( el._attrs.has( 'id' ) ).to.be.true;
 
 			expect( el._styles.has( 'one' ) ).to.be.true;
-			expect( el._styles.getInlineProperty( 'one' ) ).to.equal( 'style1' );
+			expect( el._styles.getAsString( 'one' ) ).to.equal( 'style1' );
 			expect( el._styles.has( 'two' ) ).to.be.true;
-			expect( el._styles.getInlineProperty( 'two' ) ).to.equal( 'style2' );
+			expect( el._styles.getAsString( 'two' ) ).to.equal( 'style2' );
 			expect( el._styles.has( 'three' ) ).to.be.true;
-			expect( el._styles.getInlineProperty( 'three' ) ).to.equal( 'url(http://ckeditor.com)' );
+			expect( el._styles.getAsString( 'three' ) ).to.equal( 'url(http://ckeditor.com)' );
 		} );
 	} );
 
@@ -199,9 +199,9 @@ describe( 'Element', () => {
 			expect( clone ).to.not.equal( el );
 			expect( clone.name ).to.equal( el.name );
 			expect( clone._styles.has( 'color' ) ).to.be.true;
-			expect( clone._styles.getInlineProperty( 'color' ) ).to.equal( 'red' );
+			expect( clone._styles.getAsString( 'color' ) ).to.equal( 'red' );
 			expect( clone._styles.has( 'font-size' ) ).to.be.true;
-			expect( clone._styles.getInlineProperty( 'font-size' ) ).to.equal( '12px' );
+			expect( clone._styles.getAsString( 'font-size' ) ).to.equal( '12px' );
 		} );
 
 		it( 'should clone custom properties', () => {

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

@@ -45,6 +45,6 @@ describe( 'Background styles normalization', () => {
 		styles.setTo( 'background:#f00;' );
 
 		expect( styles.toString() ).to.equal( 'background-color:#f00;' );
-		expect( styles.getInlineProperty( 'background-color' ) ).to.equal( '#f00' );
+		expect( styles.getAsString( 'background-color' ) ).to.equal( '#f00' );
 	} );
 } );

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

@@ -68,9 +68,9 @@ describe( 'Border styles normalization', () => {
 			'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' );
-		expect( styles.getInlineProperty( 'border-width' ) ).to.equal( '1px' );
+		expect( styles.getAsString( 'border-color' ) ).to.equal( 'blue' );
+		expect( styles.getAsString( 'border-style' ) ).to.equal( 'solid' );
+		expect( styles.getAsString( 'border-width' ) ).to.equal( '1px' );
 	} );
 
 	it( 'should output only defined inline styles', () => {
@@ -82,7 +82,7 @@ describe( 'Border styles normalization', () => {
 
 		expect( styles.toString( 'border' ) ).to.equal( 'border-top:blue;' );
 		// TODO: expect( styles.has( 'border-top-color' ) ).to.be.true;
-		// expect( styles.getInlineProperty( 'border-top-color' ) ).to.equal( 'blue' );
+		// expect( styles.getAsString( 'border-top-color' ) ).to.equal( 'blue' );
 	} );
 
 	it( 'should output inline shorthand rules #2', () => {
@@ -95,10 +95,10 @@ describe( 'Border styles normalization', () => {
 			'border-top:7px dotted #ccc;'
 		);
 
-		expect( styles.getInlineProperty( 'border' ) ).to.be.undefined;
-		expect( styles.getInlineProperty( 'border-color' ) ).to.equal( '#ccc blue blue #665511' );
-		expect( styles.getInlineProperty( 'border-style' ) ).to.equal( 'dotted solid solid dashed' );
-		expect( styles.getInlineProperty( 'border-width' ) ).to.equal( '7px 1px 1px 2.7em' );
+		expect( styles.getAsString( 'border' ) ).to.be.undefined;
+		expect( styles.getAsString( 'border-color' ) ).to.equal( '#ccc blue blue #665511' );
+		expect( styles.getAsString( 'border-style' ) ).to.equal( 'dotted solid solid dashed' );
+		expect( styles.getAsString( 'border-width' ) ).to.equal( '7px 1px 1px 2.7em' );
 	} );
 
 	it( 'should parse border + border-position(only color defined)', () => {
@@ -142,10 +142,10 @@ describe( 'Border styles normalization', () => {
 			'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' );
-		expect( styles.getInlineProperty( 'border-style' ) ).to.equal( 'dotted solid solid dashed' );
-		expect( styles.getInlineProperty( 'border-width' ) ).to.equal( '7px 1px 1px 2.7em' );
+		expect( styles.getAsString( 'border' ) ).to.be.undefined;
+		expect( styles.getAsString( 'border-color' ) ).to.equal( '#ccc blue blue #665511' );
+		expect( styles.getAsString( 'border-style' ) ).to.equal( 'dotted solid solid dashed' );
+		expect( styles.getAsString( 'border-width' ) ).to.equal( '7px 1px 1px 2.7em' );
 	} );
 
 	it( 'should output', () => {
@@ -159,14 +159,14 @@ describe( 'Border styles normalization', () => {
 			'border-top:1px solid;'
 		);
 
-		expect( styles.getInlineProperty( 'border' ) ).to.be.undefined;
-		expect( styles.getInlineProperty( 'border-color' ) ).to.be.undefined;
-		expect( styles.getInlineProperty( 'border-style' ) ).to.equal( 'solid' );
-		expect( styles.getInlineProperty( 'border-width' ) ).to.equal( '1px' );
-		expect( styles.getInlineProperty( 'border-top' ) ).to.equal( '1px solid' );
-		expect( styles.getInlineProperty( 'border-right' ) ).to.equal( '1px solid' );
-		expect( styles.getInlineProperty( 'border-bottom' ) ).to.equal( '1px solid' );
-		expect( styles.getInlineProperty( 'border-left' ) ).to.equal( '1px solid' );
+		expect( styles.getAsString( 'border' ) ).to.be.undefined;
+		expect( styles.getAsString( 'border-color' ) ).to.be.undefined;
+		expect( styles.getAsString( 'border-style' ) ).to.equal( 'solid' );
+		expect( styles.getAsString( 'border-width' ) ).to.equal( '1px' );
+		expect( styles.getAsString( 'border-top' ) ).to.equal( '1px solid' );
+		expect( styles.getAsString( 'border-right' ) ).to.equal( '1px solid' );
+		expect( styles.getAsString( 'border-bottom' ) ).to.equal( '1px solid' );
+		expect( styles.getAsString( 'border-left' ) ).to.equal( '1px solid' );
 	} );
 
 	it( 'should output border with only style shorthand (style)', () => {
@@ -178,14 +178,14 @@ describe( 'Border styles normalization', () => {
 			'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' );
-		expect( styles.getInlineProperty( 'border-width' ) ).to.be.undefined;
-		expect( styles.getInlineProperty( 'border-top' ) ).to.equal( 'solid' );
-		expect( styles.getInlineProperty( 'border-right' ) ).to.equal( 'solid' );
-		expect( styles.getInlineProperty( 'border-bottom' ) ).to.equal( 'solid' );
-		expect( styles.getInlineProperty( 'border-left' ) ).to.equal( 'solid' );
+		expect( styles.getAsString( 'border' ) ).to.be.undefined;
+		expect( styles.getAsString( 'border-color' ) ).to.be.undefined;
+		expect( styles.getAsString( 'border-style' ) ).to.equal( 'solid' );
+		expect( styles.getAsString( 'border-width' ) ).to.be.undefined;
+		expect( styles.getAsString( 'border-top' ) ).to.equal( 'solid' );
+		expect( styles.getAsString( 'border-right' ) ).to.equal( 'solid' );
+		expect( styles.getAsString( 'border-bottom' ) ).to.equal( 'solid' );
+		expect( styles.getAsString( 'border-left' ) ).to.equal( 'solid' );
 	} );
 
 	it( 'should output border with only style shorthand (color)', () => {
@@ -197,14 +197,14 @@ describe( 'Border styles normalization', () => {
 			'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;
-		expect( styles.getInlineProperty( 'border-width' ) ).to.be.undefined;
-		expect( styles.getInlineProperty( 'border-top' ) ).to.equal( '#f00' );
-		expect( styles.getInlineProperty( 'border-right' ) ).to.equal( '#f00' );
-		expect( styles.getInlineProperty( 'border-bottom' ) ).to.equal( '#f00' );
-		expect( styles.getInlineProperty( 'border-left' ) ).to.equal( '#f00' );
+		expect( styles.getAsString( 'border' ) ).to.be.undefined;
+		expect( styles.getAsString( 'border-color' ) ).to.equal( '#f00' );
+		expect( styles.getAsString( 'border-style' ) ).to.be.undefined;
+		expect( styles.getAsString( 'border-width' ) ).to.be.undefined;
+		expect( styles.getAsString( 'border-top' ) ).to.equal( '#f00' );
+		expect( styles.getAsString( 'border-right' ) ).to.equal( '#f00' );
+		expect( styles.getAsString( 'border-bottom' ) ).to.equal( '#f00' );
+		expect( styles.getAsString( 'border-left' ) ).to.equal( '#f00' );
 	} );
 
 	it( 'should output border with only style shorthand (width)', () => {
@@ -216,14 +216,14 @@ describe( 'Border styles normalization', () => {
 			'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;
-		expect( styles.getInlineProperty( 'border-width' ) ).to.equal( '1px' );
-		expect( styles.getInlineProperty( 'border-top' ) ).to.equal( '1px' );
-		expect( styles.getInlineProperty( 'border-right' ) ).to.equal( '1px' );
-		expect( styles.getInlineProperty( 'border-bottom' ) ).to.equal( '1px' );
-		expect( styles.getInlineProperty( 'border-left' ) ).to.equal( '1px' );
+		expect( styles.getAsString( 'border' ) ).to.be.undefined;
+		expect( styles.getAsString( 'border-color' ) ).to.be.undefined;
+		expect( styles.getAsString( 'border-style' ) ).to.be.undefined;
+		expect( styles.getAsString( 'border-width' ) ).to.equal( '1px' );
+		expect( styles.getAsString( 'border-top' ) ).to.equal( '1px' );
+		expect( styles.getAsString( 'border-right' ) ).to.equal( '1px' );
+		expect( styles.getAsString( 'border-bottom' ) ).to.equal( '1px' );
+		expect( styles.getAsString( 'border-left' ) ).to.equal( '1px' );
 	} );
 
 	describe( 'normalized values getters', () => {
@@ -256,25 +256,25 @@ describe( 'Border styles normalization', () => {
 		it( 'should output border-top', () => {
 			styles.setTo( 'border:1px solid #f00' );
 
-			expect( styles.getInlineProperty( 'border-top' ) ).to.equal( '1px solid #f00' );
+			expect( styles.getAsString( 'border-top' ) ).to.equal( '1px solid #f00' );
 		} );
 
 		it( 'should output border-right', () => {
 			styles.setTo( 'border:1px solid #f00' );
 
-			expect( styles.getInlineProperty( 'border-right' ) ).to.equal( '1px solid #f00' );
+			expect( styles.getAsString( 'border-right' ) ).to.equal( '1px solid #f00' );
 		} );
 
 		it( 'should output border-bottom', () => {
 			styles.setTo( 'border:1px solid #f00' );
 
-			expect( styles.getInlineProperty( 'border-bottom' ) ).to.equal( '1px solid #f00' );
+			expect( styles.getAsString( 'border-bottom' ) ).to.equal( '1px solid #f00' );
 		} );
 
 		it( 'should output border-left', () => {
 			styles.setTo( 'border:1px solid #f00' );
 
-			expect( styles.getInlineProperty( 'border-left' ) ).to.equal( '1px solid #f00' );
+			expect( styles.getAsString( 'border-left' ) ).to.equal( '1px solid #f00' );
 		} );
 	} );
 
@@ -597,10 +597,10 @@ describe( 'Border styles normalization', () => {
 				'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' );
-			expect( styles.getInlineProperty( 'border-bottom' ) ).to.equal( '3.0pt dotted #FFC000' );
-			expect( styles.getInlineProperty( 'border-left' ) ).to.equal( 'none' );
+			expect( styles.getAsString( 'border-top' ) ).to.equal( 'none' );
+			expect( styles.getAsString( 'border-right' ) ).to.equal( '3.0pt dotted #FFC000' );
+			expect( styles.getAsString( 'border-bottom' ) ).to.equal( '3.0pt dotted #FFC000' );
+			expect( styles.getAsString( 'border-left' ) ).to.equal( 'none' );
 		} );
 	} );
 

+ 34 - 34
packages/ckeditor5-engine/tests/view/styles/marginstyles.js

@@ -63,66 +63,66 @@ describe( 'Margin styles normalizer', () => {
 		styles.setTo( 'margin:1px;' );
 
 		expect( styles.toString() ).to.equal( 'margin:1px;' );
-		expect( styles.getInlineProperty( 'margin' ) ).to.equal( '1px' );
-		expect( styles.getInlineProperty( 'margin-top' ) ).to.equal( '1px' );
-		expect( styles.getInlineProperty( 'margin-right' ) ).to.equal( '1px' );
-		expect( styles.getInlineProperty( 'margin-bottom' ) ).to.equal( '1px' );
-		expect( styles.getInlineProperty( 'margin-left' ) ).to.equal( '1px' );
+		expect( styles.getAsString( 'margin' ) ).to.equal( '1px' );
+		expect( styles.getAsString( 'margin-top' ) ).to.equal( '1px' );
+		expect( styles.getAsString( 'margin-right' ) ).to.equal( '1px' );
+		expect( styles.getAsString( 'margin-bottom' ) ).to.equal( '1px' );
+		expect( styles.getAsString( 'margin-left' ) ).to.equal( '1px' );
 	} );
 
 	it( 'should output inline style (2 values defined)', () => {
 		styles.setTo( 'margin:1px .34cm;' );
 
 		expect( styles.toString() ).to.equal( 'margin:1px .34cm;' );
-		expect( styles.getInlineProperty( 'margin' ) ).to.equal( '1px .34cm' );
-		expect( styles.getInlineProperty( 'margin-top' ) ).to.equal( '1px' );
-		expect( styles.getInlineProperty( 'margin-right' ) ).to.equal( '.34cm' );
-		expect( styles.getInlineProperty( 'margin-bottom' ) ).to.equal( '1px' );
-		expect( styles.getInlineProperty( 'margin-left' ) ).to.equal( '.34cm' );
+		expect( styles.getAsString( 'margin' ) ).to.equal( '1px .34cm' );
+		expect( styles.getAsString( 'margin-top' ) ).to.equal( '1px' );
+		expect( styles.getAsString( 'margin-right' ) ).to.equal( '.34cm' );
+		expect( styles.getAsString( 'margin-bottom' ) ).to.equal( '1px' );
+		expect( styles.getAsString( 'margin-left' ) ).to.equal( '.34cm' );
 	} );
 
 	it( 'should output inline style (3 values defined)', () => {
 		styles.setTo( 'margin:1px .34cm 90.1rem;' );
 
 		expect( styles.toString() ).to.equal( 'margin:1px .34cm 90.1rem;' );
-		expect( styles.getInlineProperty( 'margin' ) ).to.equal( '1px .34cm 90.1rem' );
-		expect( styles.getInlineProperty( 'margin-top' ) ).to.equal( '1px' );
-		expect( styles.getInlineProperty( 'margin-right' ) ).to.equal( '.34cm' );
-		expect( styles.getInlineProperty( 'margin-bottom' ) ).to.equal( '90.1rem' );
-		expect( styles.getInlineProperty( 'margin-left' ) ).to.equal( '.34cm' );
+		expect( styles.getAsString( 'margin' ) ).to.equal( '1px .34cm 90.1rem' );
+		expect( styles.getAsString( 'margin-top' ) ).to.equal( '1px' );
+		expect( styles.getAsString( 'margin-right' ) ).to.equal( '.34cm' );
+		expect( styles.getAsString( 'margin-bottom' ) ).to.equal( '90.1rem' );
+		expect( styles.getAsString( 'margin-left' ) ).to.equal( '.34cm' );
 	} );
 
 	it( 'should output inline style (3 values defined, only last different)', () => {
 		styles.setTo( 'margin:1px 1px 90.1rem;' );
 
 		expect( styles.toString() ).to.equal( 'margin:1px 1px 90.1rem;' );
-		expect( styles.getInlineProperty( 'margin' ) ).to.equal( '1px 1px 90.1rem' );
-		expect( styles.getInlineProperty( 'margin-top' ) ).to.equal( '1px' );
-		expect( styles.getInlineProperty( 'margin-right' ) ).to.equal( '1px' );
-		expect( styles.getInlineProperty( 'margin-bottom' ) ).to.equal( '90.1rem' );
-		expect( styles.getInlineProperty( 'margin-left' ) ).to.equal( '1px' );
+		expect( styles.getAsString( 'margin' ) ).to.equal( '1px 1px 90.1rem' );
+		expect( styles.getAsString( 'margin-top' ) ).to.equal( '1px' );
+		expect( styles.getAsString( 'margin-right' ) ).to.equal( '1px' );
+		expect( styles.getAsString( 'margin-bottom' ) ).to.equal( '90.1rem' );
+		expect( styles.getAsString( 'margin-left' ) ).to.equal( '1px' );
 	} );
 
 	it( 'should output inline style (4 values defined)', () => {
 		styles.setTo( 'margin:1px .34cm 90.1rem thick;' );
 
 		expect( styles.toString() ).to.equal( 'margin:1px .34cm 90.1rem thick;' );
-		expect( styles.getInlineProperty( 'margin' ) ).to.equal( '1px .34cm 90.1rem thick' );
-		expect( styles.getInlineProperty( 'margin-top' ) ).to.equal( '1px' );
-		expect( styles.getInlineProperty( 'margin-right' ) ).to.equal( '.34cm' );
-		expect( styles.getInlineProperty( 'margin-bottom' ) ).to.equal( '90.1rem' );
-		expect( styles.getInlineProperty( 'margin-left' ) ).to.equal( 'thick' );
+		expect( styles.getAsString( 'margin' ) ).to.equal( '1px .34cm 90.1rem thick' );
+		expect( styles.getAsString( 'margin-top' ) ).to.equal( '1px' );
+		expect( styles.getAsString( 'margin-right' ) ).to.equal( '.34cm' );
+		expect( styles.getAsString( 'margin-bottom' ) ).to.equal( '90.1rem' );
+		expect( styles.getAsString( 'margin-left' ) ).to.equal( 'thick' );
 	} );
 
 	it( 'should output inline style (4 values defined, only last different)', () => {
 		styles.setTo( 'margin:1px 1px 1px thick;' );
 
 		expect( styles.toString() ).to.equal( 'margin:1px 1px 1px thick;' );
-		expect( styles.getInlineProperty( 'margin' ) ).to.equal( '1px 1px 1px thick' );
-		expect( styles.getInlineProperty( 'margin-top' ) ).to.equal( '1px' );
-		expect( styles.getInlineProperty( 'margin-right' ) ).to.equal( '1px' );
-		expect( styles.getInlineProperty( 'margin-bottom' ) ).to.equal( '1px' );
-		expect( styles.getInlineProperty( 'margin-left' ) ).to.equal( 'thick' );
+		expect( styles.getAsString( 'margin' ) ).to.equal( '1px 1px 1px thick' );
+		expect( styles.getAsString( 'margin-top' ) ).to.equal( '1px' );
+		expect( styles.getAsString( 'margin-right' ) ).to.equal( '1px' );
+		expect( styles.getAsString( 'margin-bottom' ) ).to.equal( '1px' );
+		expect( styles.getAsString( 'margin-left' ) ).to.equal( 'thick' );
 	} );
 
 	describe( 'margin-*', () => {
@@ -152,28 +152,28 @@ describe( 'Margin styles normalizer', () => {
 			styles.setTo( 'margin-top:1px;' );
 
 			expect( styles.toString() ).to.equal( 'margin-top:1px;' );
-			expect( styles.getInlineProperty( 'margin-top' ) ).to.equal( '1px' );
+			expect( styles.getAsString( 'margin-top' ) ).to.equal( '1px' );
 		} );
 
 		it( 'should output margin-right', () => {
 			styles.setTo( 'margin-right:1px;' );
 
 			expect( styles.toString() ).to.equal( 'margin-right:1px;' );
-			expect( styles.getInlineProperty( 'margin-right' ) ).to.equal( '1px' );
+			expect( styles.getAsString( 'margin-right' ) ).to.equal( '1px' );
 		} );
 
 		it( 'should output margin-bottom', () => {
 			styles.setTo( 'margin-bottom:1px;' );
 
 			expect( styles.toString() ).to.equal( 'margin-bottom:1px;' );
-			expect( styles.getInlineProperty( 'margin-bottom' ) ).to.equal( '1px' );
+			expect( styles.getAsString( 'margin-bottom' ) ).to.equal( '1px' );
 		} );
 
 		it( 'should output margin-left', () => {
 			styles.setTo( 'margin-left:1px;' );
 
 			expect( styles.toString() ).to.equal( 'margin-left:1px;' );
-			expect( styles.getInlineProperty( 'margin-left' ) ).to.equal( '1px' );
+			expect( styles.getAsString( 'margin-left' ) ).to.equal( '1px' );
 		} );
 	} );
 } );

+ 23 - 23
packages/ckeditor5-engine/tests/view/stylesmap.js

@@ -72,46 +72,46 @@ describe( 'StylesMap', () => {
 
 			it( 'should work with both types of quotes and ignore values inside quotes', () => {
 				stylesMap.setTo( 'background-image:url("im;color:g.jpg")' );
-				expect( stylesMap.getInlineProperty( 'background-image' ) ).to.equal( 'url("im;color:g.jpg")' );
+				expect( stylesMap.getAsString( 'background-image' ) ).to.equal( 'url("im;color:g.jpg")' );
 
 				stylesMap.setTo( 'background-image:url(\'im;color:g.jpg\')' );
-				expect( stylesMap.getInlineProperty( 'background-image' ) ).to.equal( 'url(\'im;color:g.jpg\')' );
+				expect( stylesMap.getAsString( 'background-image' ) ).to.equal( 'url(\'im;color:g.jpg\')' );
 			} );
 
 			it( 'should not be confused by whitespaces', () => {
 				stylesMap.setTo( '\ncolor:\n red ' );
 
-				expect( stylesMap.getInlineProperty( 'color' ) ).to.equal( 'red' );
+				expect( stylesMap.getAsString( 'color' ) ).to.equal( 'red' );
 			} );
 
 			it( 'should not be confused by duplicated semicolon', () => {
 				stylesMap.setTo( 'color: red;; display: inline' );
 
-				expect( stylesMap.getInlineProperty( 'color' ) ).to.equal( 'red' );
-				expect( stylesMap.getInlineProperty( 'display' ) ).to.equal( 'inline' );
+				expect( stylesMap.getAsString( 'color' ) ).to.equal( 'red' );
+				expect( stylesMap.getAsString( 'display' ) ).to.equal( 'inline' );
 			} );
 
 			it( 'should not throw when value is missing', () => {
 				stylesMap.setTo( 'color:; display: inline' );
 
-				expect( stylesMap.getInlineProperty( 'color' ) ).to.equal( '' );
-				expect( stylesMap.getInlineProperty( 'display' ) ).to.equal( 'inline' );
+				expect( stylesMap.getAsString( 'color' ) ).to.equal( '' );
+				expect( stylesMap.getAsString( 'display' ) ).to.equal( 'inline' );
 			} );
 
 			it( 'should not throw when colon is duplicated', () => {
 				stylesMap.setTo( 'color:: red; display: inline' );
 
 				// The result makes no sense, but here we just check that the algorithm doesn't crash.
-				expect( stylesMap.getInlineProperty( 'color' ) ).to.equal( ': red' );
-				expect( stylesMap.getInlineProperty( 'display' ) ).to.equal( 'inline' );
+				expect( stylesMap.getAsString( 'color' ) ).to.equal( ': red' );
+				expect( stylesMap.getAsString( 'display' ) ).to.equal( 'inline' );
 			} );
 
 			it( 'should not throw when random stuff passed', () => {
 				stylesMap.setTo( 'color: red;:; ;;" ":  display: inline; \'aaa;:' );
 
 				// The result makes no sense, but here we just check that the algorithm doesn't crash.
-				expect( stylesMap.getInlineProperty( 'color' ) ).to.equal( 'red' );
-				expect( stylesMap.getInlineProperty( 'display' ) ).to.be.undefined;
+				expect( stylesMap.getAsString( 'color' ) ).to.equal( 'red' );
+				expect( stylesMap.getAsString( 'display' ) ).to.be.undefined;
 			} );
 		} );
 	} );
@@ -128,11 +128,11 @@ describe( 'StylesMap', () => {
 		} );
 	} );
 
-	describe( 'getInlineProperty', () => {
+	describe( 'getAsString()', () => {
 		it( 'should return empty string for missing shorthand', () => {
 			stylesMap.setTo( 'margin-top:1px' );
 
-			expect( stylesMap.getInlineProperty( 'margin' ) ).to.be.undefined;
+			expect( stylesMap.getAsString( 'margin' ) ).to.be.undefined;
 		} );
 	} );
 
@@ -176,37 +176,37 @@ describe( 'StylesMap', () => {
 		it( 'should insert new property (empty styles)', () => {
 			stylesMap.set( 'color', 'blue' );
 
-			expect( stylesMap.getInlineProperty( 'color' ) ).to.equal( 'blue' );
+			expect( stylesMap.getAsString( 'color' ) ).to.equal( 'blue' );
 		} );
 
 		it( 'should insert new property (other properties are set)', () => {
 			stylesMap.setTo( 'margin: 1px;' );
 			stylesMap.set( 'color', 'blue' );
 
-			expect( stylesMap.getInlineProperty( 'color' ) ).to.equal( 'blue' );
+			expect( stylesMap.getAsString( 'color' ) ).to.equal( 'blue' );
 		} );
 
 		it( 'should overwrite property', () => {
 			stylesMap.setTo( 'color: red;' );
 			stylesMap.set( 'color', 'blue' );
 
-			expect( stylesMap.getInlineProperty( 'color' ) ).to.equal( 'blue' );
+			expect( stylesMap.getAsString( 'color' ) ).to.equal( 'blue' );
 		} );
 
 		it( 'should set multiple styles by providing an object', () => {
 			stylesMap.setTo( 'color: red;' );
 			stylesMap.set( { color: 'blue', foo: '1px' } );
 
-			expect( stylesMap.getInlineProperty( 'color' ) ).to.equal( 'blue' );
-			expect( stylesMap.getInlineProperty( 'foo-top' ) ).to.equal( '1px' );
+			expect( stylesMap.getAsString( 'color' ) ).to.equal( 'blue' );
+			expect( stylesMap.getAsString( 'foo-top' ) ).to.equal( '1px' );
 		} );
 
 		it( 'should set object property', () => {
 			stylesMap.setTo( 'foo:1px;' );
 			stylesMap.set( 'foo', { right: '2px' } );
 
-			expect( stylesMap.getInlineProperty( 'foo-left' ) ).to.equal( '1px' );
-			expect( stylesMap.getInlineProperty( 'foo-right' ) ).to.equal( '2px' );
+			expect( stylesMap.getAsString( 'foo-left' ) ).to.equal( '1px' );
+			expect( stylesMap.getAsString( 'foo-right' ) ).to.equal( '2px' );
 		} );
 	} );
 
@@ -214,14 +214,14 @@ describe( 'StylesMap', () => {
 		it( 'should do nothing if property is not set', () => {
 			stylesMap.remove( 'color' );
 
-			expect( stylesMap.getInlineProperty( 'color' ) ).to.be.undefined;
+			expect( stylesMap.getAsString( 'color' ) ).to.equal( '' );
 		} );
 
 		it( 'should insert new property (other properties are set)', () => {
 			stylesMap.setTo( 'color:blue' );
 			stylesMap.remove( 'color' );
 
-			expect( stylesMap.getInlineProperty( 'color' ) ).to.be.undefined;
+			expect( stylesMap.getAsString( 'color' ) ).to.equal( '' );
 		} );
 
 		it( 'should remove normalized property', () => {
@@ -229,7 +229,7 @@ describe( 'StylesMap', () => {
 
 			stylesMap.remove( 'margin-top' );
 
-			expect( stylesMap.getInlineProperty( 'margin-top' ) ).to.be.undefined;
+			expect( stylesMap.getAsString( 'margin-top' ) ).to.be.undefined;
 		} );
 	} );