소스 검색

Rename root id to root name to match naming in other components.

Piotrek Koszuliński 9 년 전
부모
커밋
b92b4b71ea
2개의 변경된 파일24개의 추가작업 그리고 24개의 파일을 삭제
  1. 21 21
      packages/ckeditor5-engine/src/treemodel/document.js
  2. 3 3
      packages/ckeditor5-engine/tests/treemodel/document/document.js

+ 21 - 21
packages/ckeditor5-engine/src/treemodel/document.js

@@ -147,27 +147,27 @@ export default class Document {
 	/**
 	 * Creates a new top-level root.
 	 *
-	 * @param {String|Symbol} id Unique root id.
-	 * @param {String} name Element name.
+	 * @param {String|Symbol} rootName Unique root name.
+	 * @param {String} elementName Element name.
 	 * @returns {core.treeModel.RootElement} Created root.
 	 */
-	createRoot( id, name ) {
-		if ( this._roots.has( id ) ) {
+	createRoot( rootName, elementName ) {
+		if ( this._roots.has( rootName ) ) {
 			/**
-			 * Root with specified id already exists.
+			 * Root with specified name already exists.
 			 *
-			 * @error document-createRoot-id-exists
+			 * @error document-createRoot-name-exists
 			 * @param {core.treeModel.Document} doc
-			 * @param {String} id
+			 * @param {String} name
 			 */
 			throw new CKEditorError(
-				'document-createRoot-id-exists: Root with specified id already exists.',
-				{ id: id }
+				'document-createRoot-name-exists: Root with specified name already exists.',
+				{ name: rootName }
 			);
 		}
 
-		const root = new RootElement( this, name );
-		this._roots.set( id, root );
+		const root = new RootElement( this, elementName );
+		this._roots.set( rootName, root );
 
 		return root;
 	}
@@ -205,26 +205,26 @@ export default class Document {
 	}
 
 	/**
-	 * Returns top-level root by it's id.
+	 * Returns top-level root by its name.
 	 *
-	 * @param {String|Symbol} id Unique root id.
-	 * @returns {core.treeModel.RootElement} Root registered under given id.
+	 * @param {String|Symbol} name Unique root name.
+	 * @returns {core.treeModel.RootElement} Root registered under given name.
 	 */
-	getRoot( id ) {
-		if ( !this._roots.has( id ) ) {
+	getRoot( name ) {
+		if ( !this._roots.has( name ) ) {
 			/**
-			 * Root with specified id does not exist.
+			 * Root with specified name does not exist.
 			 *
 			 * @error document-getRoot-root-not-exist
-			 * @param {String} id
+			 * @param {String} name
 			 */
 			throw new CKEditorError(
-				'document-getRoot-root-not-exist: Root with specified id does not exist.',
-				{ id: id }
+				'document-getRoot-root-not-exist: Root with specified name does not exist.',
+				{ name: name }
 			);
 		}
 
-		return this._roots.get( id );
+		return this._roots.get( name );
 	}
 
 	/**

+ 3 - 3
packages/ckeditor5-engine/tests/treemodel/document/document.js

@@ -38,19 +38,19 @@ describe( 'Document', () => {
 			expect( root.getChildCount() ).to.equal( 0 );
 		} );
 
-		it( 'should throw an error when trying to create a second root with the same id', () => {
+		it( 'should throw an error when trying to create a second root with the same name', () => {
 			doc.createRoot( 'root', 'root' );
 
 			expect(
 				() => {
 					doc.createRoot( 'root', 'root' );
 				}
-			).to.throw( CKEditorError, /document-createRoot-id-exists/ );
+			).to.throw( CKEditorError, /document-createRoot-name-exists/ );
 		} );
 	} );
 
 	describe( 'getRoot', () => {
-		it( 'should return a RootElement previously created with given id', () => {
+		it( 'should return a RootElement previously created with given name', () => {
 			let newRoot = doc.createRoot( 'root' );
 			let getRoot = doc.getRoot( 'root' );