Ver Fonte

Rename StylesMap.hasProperty() to has().

Maciej Gołaszewski há 6 anos atrás
pai
commit
8707133144

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

@@ -336,7 +336,7 @@ export default class Element extends Node {
 		// Check if styles are the same.
 		// Check if styles are the same.
 		for ( const property of this._styles.getStyleNames() ) {
 		for ( const property of this._styles.getStyleNames() ) {
 			if (
 			if (
-				!otherElement._styles.hasProperty( property ) ||
+				!otherElement._styles.has( property ) ||
 				otherElement._styles.getInlineProperty( property ) !== this._styles.getInlineProperty( property )
 				otherElement._styles.getInlineProperty( property ) !== this._styles.getInlineProperty( property )
 			) {
 			) {
 				return false;
 				return false;
@@ -437,7 +437,7 @@ export default class Element extends Node {
 	 */
 	 */
 	hasStyle( ...property ) {
 	hasStyle( ...property ) {
 		for ( const name of property ) {
 		for ( const name of property ) {
-			if ( !this._styles.hasProperty( name ) ) {
+			if ( !this._styles.has( name ) ) {
 				return false;
 				return false;
 			}
 			}
 		}
 		}

+ 9 - 9
packages/ckeditor5-engine/src/view/stylesmap.js

@@ -76,8 +76,8 @@ export default class StylesMap {
 	 *
 	 *
 	 *		styles.setTo( 'margin-left:1px;' );
 	 *		styles.setTo( 'margin-left:1px;' );
 	 *
 	 *
-	 *		styles.hasProperty( 'margin-left' );    // returns true
-	 *		styles.hasProperty( 'padding' );        // returns false
+	 *		styles.has( 'margin-left' );    // returns true
+	 *		styles.has( 'padding' );        // returns false
 	 *
 	 *
 	 * *Note:* This check supports normalized style names.
 	 * *Note:* This check supports normalized style names.
 	 *
 	 *
@@ -86,20 +86,20 @@ export default class StylesMap {
 	 *
 	 *
 	 *		styles.setTo( 'margin:2px;' );
 	 *		styles.setTo( 'margin:2px;' );
 	 *
 	 *
-	 *		styles.hasProperty( 'margin' );         // returns true
-	 *		styles.hasProperty( 'margin-top' );     // returns true
-	 *		styles.hasProperty( 'margin-left' );    // returns true
+	 *		styles.has( 'margin' );         // returns true
+	 *		styles.has( 'margin-top' );     // returns true
+	 *		styles.has( 'margin-left' );    // returns true
 	 *
 	 *
 	 *		styles.removeProperty( 'margin-top' );
 	 *		styles.removeProperty( 'margin-top' );
 	 *
 	 *
-	 *		styles.hasProperty( 'margin' );         // returns false
-	 *		styles.hasProperty( 'margin-top' );     // returns false
-	 *		styles.hasProperty( 'margin-left' );    // returns true
+	 *		styles.has( 'margin' );         // returns false
+	 *		styles.has( 'margin-top' );     // returns false
+	 *		styles.has( 'margin-left' );    // returns true
 	 *
 	 *
 	 * @param {String} propertyName
 	 * @param {String} propertyName
 	 * @returns {Boolean}
 	 * @returns {Boolean}
 	 */
 	 */
-	hasProperty( propertyName ) {
+	has( propertyName ) {
 		const normalized = this._styleProcessor.getNormalized( propertyName, this._styles );
 		const normalized = this._styleProcessor.getNormalized( propertyName, this._styles );
 
 
 		if ( !normalized ) {
 		if ( !normalized ) {

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

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

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

@@ -81,7 +81,7 @@ describe( 'Border styles normalization', () => {
 		} );
 		} );
 
 
 		expect( styles.getInlineStyle( 'border' ) ).to.equal( 'border-top:blue;' );
 		expect( styles.getInlineStyle( 'border' ) ).to.equal( 'border-top:blue;' );
-		// TODO: expect( styles.hasProperty( 'border-top-color' ) ).to.be.true;
+		// TODO: expect( styles.has( 'border-top-color' ) ).to.be.true;
 		// expect( styles.getInlineProperty( 'border-top-color' ) ).to.equal( 'blue' );
 		// expect( styles.getInlineProperty( 'border-top-color' ) ).to.equal( 'blue' );
 	} );
 	} );
 
 

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

@@ -136,39 +136,39 @@ describe( 'StylesMap', () => {
 		} );
 		} );
 	} );
 	} );
 
 
-	describe( 'hasProperty()', () => {
+	describe( 'has()', () => {
 		it( 'should return false if property is not set', () => {
 		it( 'should return false if property is not set', () => {
-			expect( stylesMap.hasProperty( 'bar' ) ).to.be.false;
+			expect( stylesMap.has( 'bar' ) ).to.be.false;
 		} );
 		} );
 
 
 		it( 'should return false if normalized longhand property is not set', () => {
 		it( 'should return false if normalized longhand property is not set', () => {
 			stylesMap.setTo( 'foo-top:1px' );
 			stylesMap.setTo( 'foo-top:1px' );
 
 
-			expect( stylesMap.hasProperty( 'foo' ) ).to.be.false;
+			expect( stylesMap.has( 'foo' ) ).to.be.false;
 		} );
 		} );
 
 
 		it( 'should return true if normalized longhand property is set', () => {
 		it( 'should return true if normalized longhand property is set', () => {
 			stylesMap.setTo( 'foo-top:1px' );
 			stylesMap.setTo( 'foo-top:1px' );
 
 
-			expect( stylesMap.hasProperty( 'foo-top' ) ).to.be.true;
+			expect( stylesMap.has( 'foo-top' ) ).to.be.true;
 		} );
 		} );
 
 
 		it( 'should return true if non-normalized property is set', () => {
 		it( 'should return true if non-normalized property is set', () => {
 			stylesMap.setTo( 'bar:deeppink' );
 			stylesMap.setTo( 'bar:deeppink' );
 
 
-			expect( stylesMap.hasProperty( 'bar' ) ).to.be.true;
+			expect( stylesMap.has( 'bar' ) ).to.be.true;
 		} );
 		} );
 
 
 		it( 'should return true if normalized shorthanded property is set', () => {
 		it( 'should return true if normalized shorthanded property is set', () => {
 			stylesMap.setTo( 'foo:1px' );
 			stylesMap.setTo( 'foo:1px' );
 
 
-			expect( stylesMap.hasProperty( 'foo' ) ).to.be.true;
+			expect( stylesMap.has( 'foo' ) ).to.be.true;
 		} );
 		} );
 
 
 		it( 'should return true if normalized long-hand property is set', () => {
 		it( 'should return true if normalized long-hand property is set', () => {
 			stylesMap.setTo( 'foo:1px' );
 			stylesMap.setTo( 'foo:1px' );
 
 
-			expect( stylesMap.hasProperty( 'foo-top' ) ).to.be.true;
+			expect( stylesMap.has( 'foo-top' ) ).to.be.true;
 		} );
 		} );
 	} );
 	} );