Sfoglia il codice sorgente

Renamed protected getAttrCount to _getAttrCount.

Piotr Jasiun 10 anni fa
parent
commit
27eddaada9

+ 1 - 1
packages/ckeditor5-utils/src/document/node.js

@@ -110,7 +110,7 @@ CKEDITOR.define( [ 'document/attribute', 'utils' ], function( Attribute, utils )
 		 * @protected
 		 * @returns {Number} Number of attributes.
 		 */
-		getAttrCount() {
+		_getAttrCount() {
 			var count = 0;
 
 			for ( var attr of this._attrs ) { // jshint ignore:line

+ 9 - 9
packages/ckeditor5-utils/src/document/nodelist.js

@@ -28,22 +28,22 @@ CKEDITOR.define( [
 		 * Constructor let you create a list of nodes in many ways. See examples:
 		 *
 		 *		var nodeList = new NodeList( [ new Element( p1 ), new Element( p1 ) ] );
-		 *		nodeList.length // 2
+		 *		nodeList.length; // 2
 		 *
 		 *		var nodeList = new NodeList( new Element( p ) );
-		 *		nodeList.length // 1
+		 *		nodeList.length; // 1
 		 *
 		 *		var nodeList = new NodeList( [ 'foo', new Element( p ), 'bar' ] );
-		 *		nodeList.length // 7
+		 *		nodeList.length; // 7
 		 *
 		 *		var nodeList = new NodeList( 'foo' );
-		 *		nodeList.length // 3
+		 *		nodeList.length; // 3
 		 *
-		 *		var nodeList = new NodeList( new Text( 'foo', [ attrA, attrB ] ) );
-		 *		nodeList.length // 3
-		 *		nodeList.get( 0 ).getAttrCount() // 2
-		 *		nodeList.get( 1 ).getAttrCount() // 2
-		 *		nodeList.get( 2 ).getAttrCount() // 2
+		 *		var nodeList = new NodeList( new Text( 'foo', [ new Attribute( 'bar', 'bom' ) ] ) );
+		 *		nodeList.length; // 3
+		 *		nodeList.get( 0 ).getAttr( 'bar' ); // 'bom'
+		 *		nodeList.get( 1 ).getAttr( 'bar' ); // 'bom'
+		 *		nodeList.get( 2 ).getAttr( 'bar' ); // 'bom'
 		 *
 		 *		var nodeListA = new NodeList( 'foo' );
 		 *		var nodeListB = new NodeList( nodeListA );

+ 22 - 22
packages/ckeditor5-utils/tests/document/changeoperation.js

@@ -42,7 +42,7 @@ describe( 'ChangeOperation', function() {
 		expect( doc.root.getChildCount() ).to.be.equal( 3 );
 		expect( doc.root.getChild( 0 ).hasAttr( newAttr ) ).to.be.true;
 		expect( doc.root.getChild( 1 ).hasAttr( newAttr ) ).to.be.true;
-		expect( doc.root.getChild( 2 ).getAttrCount() ).to.be.equal( 0 );
+		expect( doc.root.getChild( 2 )._getAttrCount() ).to.be.equal( 0 );
 	} );
 
 	it( 'should insert attribute to multiple ranges', function() {
@@ -70,7 +70,7 @@ describe( 'ChangeOperation', function() {
 		expect( doc.version ).to.be.equal( 1 );
 		expect( doc.root.getChildCount() ).to.be.equal( 3 );
 		expect( doc.root.getChild( 0 ).hasAttr( newAttr ) ).to.be.true;
-		expect( doc.root.getChild( 1 ).getAttrCount() ).to.be.equal( 0 );
+		expect( doc.root.getChild( 1 )._getAttrCount() ).to.be.equal( 0 );
 		expect( doc.root.getChild( 2 ).hasAttr( newAttr ) ).to.be.true;
 	} );
 
@@ -98,7 +98,7 @@ describe( 'ChangeOperation', function() {
 
 		expect( doc.version ).to.be.equal( 1 );
 		expect( doc.root.getChildCount() ).to.be.equal( 1 );
-		expect( doc.root.getChild( 0 ).getAttrCount() ).to.be.equal( 3 );
+		expect( doc.root.getChild( 0 )._getAttrCount() ).to.be.equal( 3 );
 		expect( doc.root.getChild( 0 ).hasAttr( newAttr ) ).to.be.true;
 		expect( doc.root.getChild( 0 ).hasAttr( fooAttr ) ).to.be.true;
 		expect( doc.root.getChild( 0 ).hasAttr( barAttr ) ).to.be.true;
@@ -130,11 +130,11 @@ describe( 'ChangeOperation', function() {
 
 		expect( doc.version ).to.be.equal( 1 );
 		expect( doc.root.getChildCount() ).to.be.equal( 3 );
-		expect( doc.root.getChild( 0 ).getAttrCount() ).to.be.equal( 1 );
+		expect( doc.root.getChild( 0 )._getAttrCount() ).to.be.equal( 1 );
 		expect( doc.root.getChild( 0 ).hasAttr( newAttr ) ).to.be.true;
-		expect( doc.root.getChild( 1 ).getAttrCount() ).to.be.equal( 1 );
+		expect( doc.root.getChild( 1 )._getAttrCount() ).to.be.equal( 1 );
 		expect( doc.root.getChild( 1 ).hasAttr( oldAttr ) ).to.be.true;
-		expect( doc.root.getChild( 2 ).getAttrCount() ).to.be.equal( 1 );
+		expect( doc.root.getChild( 2 )._getAttrCount() ).to.be.equal( 1 );
 		expect( doc.root.getChild( 2 ).hasAttr( newAttr ) ).to.be.true;
 	} );
 
@@ -161,11 +161,11 @@ describe( 'ChangeOperation', function() {
 
 		expect( doc.version ).to.be.equal( 1 );
 		expect( doc.root.getChildCount() ).to.be.equal( 3 );
-		expect( doc.root.getChild( 0 ).getAttrCount() ).to.be.equal( 1 );
+		expect( doc.root.getChild( 0 )._getAttrCount() ).to.be.equal( 1 );
 		expect( doc.root.getChild( 0 ).hasAttr( newAttr ) ).to.be.true;
-		expect( doc.root.getChild( 1 ).getAttrCount() ).to.be.equal( 1 );
+		expect( doc.root.getChild( 1 )._getAttrCount() ).to.be.equal( 1 );
 		expect( doc.root.getChild( 1 ).hasAttr( newAttr ) ).to.be.true;
-		expect( doc.root.getChild( 2 ).getAttrCount() ).to.be.equal( 1 );
+		expect( doc.root.getChild( 2 )._getAttrCount() ).to.be.equal( 1 );
 		expect( doc.root.getChild( 2 ).hasAttr( oldAttr ) ).to.be.true;
 	} );
 
@@ -194,7 +194,7 @@ describe( 'ChangeOperation', function() {
 
 		expect( doc.version ).to.be.equal( 1 );
 		expect( doc.root.getChildCount() ).to.be.equal( 1 );
-		expect( doc.root.getChild( 0 ).getAttrCount() ).to.be.equal( 3 );
+		expect( doc.root.getChild( 0 )._getAttrCount() ).to.be.equal( 3 );
 		expect( doc.root.getChild( 0 ).hasAttr( fooAttr ) ).to.be.true;
 		expect( doc.root.getChild( 0 ).hasAttr( x2Attr ) ).to.be.true;
 		expect( doc.root.getChild( 0 ).hasAttr( barAttr ) ).to.be.true;
@@ -224,7 +224,7 @@ describe( 'ChangeOperation', function() {
 
 		expect( doc.version ).to.be.equal( 1 );
 		expect( doc.root.getChildCount() ).to.be.equal( 1 );
-		expect( doc.root.getChild( 0 ).getAttrCount() ).to.be.equal( 2 );
+		expect( doc.root.getChild( 0 )._getAttrCount() ).to.be.equal( 2 );
 		expect( doc.root.getChild( 0 ).hasAttr( fooAttr ) ).to.be.true;
 		expect( doc.root.getChild( 0 ).hasAttr( barAttr ) ).to.be.true;
 	} );
@@ -254,9 +254,9 @@ describe( 'ChangeOperation', function() {
 
 		expect( doc.version ).to.be.equal( 1 );
 		expect( doc.root.getChildCount() ).to.be.equal( 3 );
-		expect( doc.root.getChild( 0 ).getAttrCount() ).to.be.equal( 0 );
+		expect( doc.root.getChild( 0 )._getAttrCount() ).to.be.equal( 0 );
 		expect( doc.root.getChild( 1 ).hasAttr( fooAttr ) ).to.be.true;
-		expect( doc.root.getChild( 2 ).getAttrCount() ).to.be.equal( 0 );
+		expect( doc.root.getChild( 2 )._getAttrCount() ).to.be.equal( 0 );
 	} );
 
 	it( 'should create a change operation as a reverse', function() {
@@ -311,9 +311,9 @@ describe( 'ChangeOperation', function() {
 
 		expect( doc.version ).to.be.equal( 2 );
 		expect( doc.root.getChildCount() ).to.be.equal( 3 );
-		expect( doc.root.getChild( 0 ).getAttrCount() ).to.be.equal( 0 );
-		expect( doc.root.getChild( 1 ).getAttrCount() ).to.be.equal( 0 );
-		expect( doc.root.getChild( 2 ).getAttrCount() ).to.be.equal( 0 );
+		expect( doc.root.getChild( 0 )._getAttrCount() ).to.be.equal( 0 );
+		expect( doc.root.getChild( 1 )._getAttrCount() ).to.be.equal( 0 );
+		expect( doc.root.getChild( 2 )._getAttrCount() ).to.be.equal( 0 );
 	} );
 
 	it( 'should undo change attribute by applying reverse operation', function() {
@@ -345,11 +345,11 @@ describe( 'ChangeOperation', function() {
 
 		expect( doc.version ).to.be.equal( 2 );
 		expect( doc.root.getChildCount() ).to.be.equal( 3 );
-		expect( doc.root.getChild( 0 ).getAttrCount() ).to.be.equal( 1 );
+		expect( doc.root.getChild( 0 )._getAttrCount() ).to.be.equal( 1 );
 		expect( doc.root.getChild( 0 ).hasAttr( oldAttr ) ).to.be.true;
-		expect( doc.root.getChild( 1 ).getAttrCount() ).to.be.equal( 1 );
+		expect( doc.root.getChild( 1 )._getAttrCount() ).to.be.equal( 1 );
 		expect( doc.root.getChild( 1 ).hasAttr( oldAttr ) ).to.be.true;
-		expect( doc.root.getChild( 2 ).getAttrCount() ).to.be.equal( 1 );
+		expect( doc.root.getChild( 2 )._getAttrCount() ).to.be.equal( 1 );
 		expect( doc.root.getChild( 2 ).hasAttr( oldAttr ) ).to.be.true;
 	} );
 
@@ -381,11 +381,11 @@ describe( 'ChangeOperation', function() {
 
 		expect( doc.version ).to.be.equal( 2 );
 		expect( doc.root.getChildCount() ).to.be.equal( 3 );
-		expect( doc.root.getChild( 0 ).getAttrCount() ).to.be.equal( 1 );
+		expect( doc.root.getChild( 0 )._getAttrCount() ).to.be.equal( 1 );
 		expect( doc.root.getChild( 0 ).hasAttr( fooAttr ) ).to.be.true;
-		expect( doc.root.getChild( 1 ).getAttrCount() ).to.be.equal( 1 );
+		expect( doc.root.getChild( 1 )._getAttrCount() ).to.be.equal( 1 );
 		expect( doc.root.getChild( 1 ).hasAttr( fooAttr ) ).to.be.true;
-		expect( doc.root.getChild( 2 ).getAttrCount() ).to.be.equal( 1 );
+		expect( doc.root.getChild( 2 )._getAttrCount() ).to.be.equal( 1 );
 		expect( doc.root.getChild( 2 ).hasAttr( fooAttr ) ).to.be.true;
 	} );
 

+ 2 - 2
packages/ckeditor5-utils/tests/document/character.js

@@ -27,7 +27,7 @@ describe( 'constructor', function() {
 		expect( character ).to.be.an.instanceof( Node );
 		expect( character ).to.have.property( 'character' ).that.equals( 'f' );
 		expect( character ).to.have.property( 'parent' ).that.equals( parent );
-		expect( character.getAttrCount() ).to.equals( 0 );
+		expect( character._getAttrCount() ).to.equals( 0 );
 	} );
 
 	it( 'should create character with attributes', function() {
@@ -45,7 +45,7 @@ describe( 'constructor', function() {
 		expect( character ).to.be.an.instanceof( Node );
 		expect( character ).to.have.property( 'character' ).that.equals( 'f' );
 		expect( character ).to.have.property( 'parent' ).that.equals( parent );
-		expect( character.getAttrCount() ).to.be.equals( 1 );
+		expect( character._getAttrCount() ).to.be.equals( 1 );
 		expect( character.getAttr( attr.key ) ).to.equals( attr.value );
 	} );
 } );

+ 2 - 2
packages/ckeditor5-utils/tests/document/element.js

@@ -25,7 +25,7 @@ describe( 'constructor', function() {
 		expect( element ).to.be.an.instanceof( Node );
 		expect( element ).to.have.property( 'name' ).that.equals( 'elem' );
 		expect( element ).to.have.property( 'parent' ).that.equals( parent );
-		expect( element.getAttrCount() ).to.equals( 0 );
+		expect( element._getAttrCount() ).to.equals( 0 );
 	} );
 
 	it( 'should create element with attributes', function() {
@@ -42,7 +42,7 @@ describe( 'constructor', function() {
 		expect( element ).to.be.an.instanceof( Node );
 		expect( element ).to.have.property( 'name' ).that.equals( 'elem' );
 		expect( element ).to.have.property( 'parent' ).that.equals( parent );
-		expect( element.getAttrCount() ).to.equals( 1 );
+		expect( element._getAttrCount() ).to.equals( 1 );
 		expect( element.getAttr( attr.key ) ).to.equals( attr.value );
 	} );
 

+ 5 - 5
packages/ckeditor5-utils/tests/document/node.js

@@ -113,8 +113,8 @@ describe( 'constructor', function() {
 
 		foo.removeAttr( 'attr' );
 
-		expect( foo.getAttrCount() ).to.equals( 0 );
-		expect( bar.getAttrCount() ).to.equals( 1 );
+		expect( foo._getAttrCount() ).to.equals( 0 );
+		expect( bar._getAttrCount() ).to.equals( 1 );
 	} );
 } );
 
@@ -149,7 +149,7 @@ describe( 'setAttr', function() {
 		var attr = new Attribute( 'foo', 'bar' );
 		element.setAttr( attr );
 
-		expect( element.getAttrCount() ).to.equals( 1 );
+		expect( element._getAttrCount() ).to.equals( 1 );
 		expect( element.getAttr( attr.key ) ).to.equals( attr.value );
 	} );
 
@@ -163,7 +163,7 @@ describe( 'setAttr', function() {
 
 		element.setAttr( newAttr );
 
-		expect( element.getAttrCount() ).to.equals( 1 );
+		expect( element._getAttrCount() ).to.equals( 1 );
 		expect( element.getAttr( newAttr.key ) ).to.equals( newAttr.value );
 	} );
 } );
@@ -179,7 +179,7 @@ describe( 'removeAttr', function() {
 		var element = new Element( 'elem', [ attrA, attrB, attrC ] );
 		element.removeAttr( attrB.key );
 
-		expect( element.getAttrCount() ).to.equals( 2 );
+		expect( element._getAttrCount() ).to.equals( 2 );
 		expect( element.getAttr( attrA.key ) ).to.equals( attrA.value );
 		expect( element.getAttr( attrC.key ) ).to.equals( attrC.value );
 		expect( element.getAttr( attrB.key ) ).to.be.null;