8
0
فهرست منبع

Documented a number of errors in MVC classes.

Aleksander Nowodzinski 10 سال پیش
والد
کامیت
27926d2a3c
2فایلهای تغییر یافته به همراه108 افزوده شده و 0 حذف شده
  1. 50 0
      packages/ckeditor5-engine/src/ui/controller.js
  2. 58 0
      packages/ckeditor5-engine/src/ui/view.js

+ 50 - 0
packages/ckeditor5-engine/src/ui/controller.js

@@ -63,6 +63,11 @@ CKEDITOR.define( [
 		 */
 		init() {
 			if ( this.ready ) {
+				/**
+				 * This Controller already been initialized.
+				 *
+				 * @error ui-controller-init-reinit
+				 */
 				throw new CKEditorError( 'ui-controller-init-reinit: This Controller already been initialized.' );
 			}
 
@@ -126,16 +131,31 @@ CKEDITOR.define( [
 		 */
 		addChild( collectionName, childController, index ) {
 			if ( !collectionName ) {
+				/**
+				 * The name of the collection is required.
+				 *
+				 * @error ui-controller-addchild-badcname
+				 */
 				throw new CKEditorError( 'ui-controller-addchild-badcname' );
 			}
 
 			const collection = this._collections.get( collectionName );
 
 			if ( !collection ) {
+				/**
+				 * There is no collection of given name.
+				 *
+				 * @error ui-controller-addchild-nocol
+				 */
 				throw new CKEditorError( 'ui-controller-addchild-nocol' );
 			}
 
 			if ( !childController || !( childController instanceof Controller ) ) {
+				/**
+				 * Passed controller is of a wrong type.
+				 *
+				 * @error ui-controller-addchild-badtype
+				 */
 				throw new CKEditorError( 'ui-controller-addchild-badtype' );
 			}
 
@@ -170,16 +190,31 @@ CKEDITOR.define( [
 		 */
 		removeChild( collectionName, childController ) {
 			if ( !collectionName ) {
+				/**
+				 * Collection name is required.
+				 *
+				 * @error ui-controller-removechild-badcname
+				 */
 				throw new CKEditorError( 'ui-controller-removechild-badcname' );
 			}
 
 			const collection = this._collections.get( collectionName );
 
 			if ( !collection ) {
+				/**
+				 * There's no collection of given name.
+				 *
+				 * @error ui-controller-removechild-nocol
+				 */
 				throw new CKEditorError( 'ui-controller-removechild-nocol' );
 			}
 
 			if ( !childController || !( childController instanceof Controller ) ) {
+				/**
+				 * The controller is of a wrong type.
+				 *
+				 * @error ui-controller-removechild-badtype
+				 */
 				throw new CKEditorError( 'ui-controller-removechild-badtype' );
 			}
 
@@ -204,6 +239,11 @@ CKEDITOR.define( [
 			const collection = this._collections.get( collectionName );
 
 			if ( !collection ) {
+				/**
+				 * There's no collection of such name.
+				 *
+				 * @error ui-controller-getchild-nocol
+				 */
 				throw new CKEditorError( 'ui-controller-getchild-nocol' );
 			}
 
@@ -222,6 +262,11 @@ CKEDITOR.define( [
 			const that = this;
 
 			if ( !( collection instanceof Collection ) ) {
+				/**
+				 * The collection must be an instance of Collection.
+				 *
+				 * @error ui-controller-register-badtype
+				 */
 				throw new CKEditorError( 'ui-controller-register-badtype' );
 			}
 
@@ -230,6 +275,11 @@ CKEDITOR.define( [
 			} else {
 				if ( registered !== collection ) {
 					if ( !override ) {
+						/**
+						 * Overriding is possible only when `override` flag is set.
+						 *
+						 * @error ui-controller-register-noverride
+						 */
 						throw new CKEditorError( 'ui-controller-register-noverride' );
 					}
 

+ 58 - 0
packages/ckeditor5-engine/src/ui/view.js

@@ -121,16 +121,31 @@ CKEDITOR.define( [
 		 */
 		addChild( regionName, childView, index ) {
 			if ( !regionName ) {
+				/**
+				 * The name of the region is required.
+				 *
+				 * @error ui-view-addchild-badrname
+				 */
 				throw new CKEditorError( 'ui-view-addchild-badrname' );
 			}
 
 			const region = this.regions.get( regionName );
 
 			if ( !region ) {
+				/**
+				 * No such region of given name.
+				 *
+				 * @error ui-view-addchild-noreg
+				 */
 				throw new CKEditorError( 'ui-view-addchild-noreg' );
 			}
 
 			if ( !childView || !( childView instanceof View ) ) {
+				/**
+				 * Child view must be an instance of View.
+				 *
+				 * @error ui-view-addchild-badtype
+				 */
 				throw new CKEditorError( 'ui-view-addchild-badtype' );
 			}
 
@@ -146,12 +161,22 @@ CKEDITOR.define( [
 		 */
 		removeChild( regionName, childView ) {
 			if ( !childView || !( childView instanceof View ) ) {
+				/**
+				 * The view must be an instance of View.
+				 *
+				 * @error ui-view-removechild-badtype
+				 */
 				throw new CKEditorError( 'ui-view-removechild-badtype' );
 			}
 
 			const region = this.regions.get( regionName );
 
 			if ( !region ) {
+				/**
+				 * No such region of given name.
+				 *
+				 * @error ui-view-removechild-noreg
+				 */
 				throw new CKEditorError( 'ui-view-removechild-noreg' );
 			}
 
@@ -172,6 +197,11 @@ CKEDITOR.define( [
 			const region = this.regions.get( regionName );
 
 			if ( !region ) {
+				/**
+				 * No such region of given name.
+				 *
+				 * @error ui-view-getchild-noreg
+				 */
 				throw new CKEditorError( 'ui-view-getchild-noreg' );
 			}
 
@@ -212,12 +242,22 @@ CKEDITOR.define( [
 				regionName = args[ 0 ].name;
 				region = args[ 0 ];
 			} else {
+				/**
+				 * A name of the region or an instance of Region is required.
+				 *
+				 * @error ui-view-register-wrongtype
+				 */
 				throw new CKEditorError( 'ui-view-register-wrongtype' );
 			}
 
 			const regionSelector = args[ 1 ];
 
 			if ( !regionSelector || !isValidRegionSelector( regionSelector ) ) {
+				/**
+				 * The selector must be String, Function or `true`.
+				 *
+				 * @error ui-view-register-badselector
+				 */
 				throw new CKEditorError( 'ui-view-register-badselector' );
 			}
 
@@ -228,6 +268,11 @@ CKEDITOR.define( [
 			} else {
 				if ( registered !== region ) {
 					if ( !args[ 2 ] ) {
+						/**
+						 * Overriding is possible only when `override` flag is set.
+						 *
+						 * @error ui-view-register-override
+						 */
 						throw new CKEditorError( 'ui-view-register-override' );
 					}
 
@@ -251,6 +296,12 @@ CKEDITOR.define( [
 			}
 
 			if ( !this.template ) {
+				/**
+				 * Attempting to access an element of a view, which has no `template`
+				 * property.
+				 *
+				 * @error ui-view-notemplate
+				 */
 				throw new CKEditorError( 'ui-view-notemplate' );
 			}
 
@@ -438,6 +489,13 @@ CKEDITOR.define( [
 
 	const validSelectorTypes = new Set( [ 'string', 'boolean', 'function' ] );
 
+	/**
+	 * Check whether region selector is valid.
+	 *
+	 * @protected
+	 * @param {*} selector Selector to be checked.
+	 * @returns {Boolean}
+	 */
 	function isValidRegionSelector( selector ) {
 		return validSelectorTypes.has( typeof selector ) && selector !== false;
 	}