浏览代码

Introduced the Watchdog#_instance method.

Maciej Bukowski 5 年之前
父节点
当前提交
9922c4160d
共有 2 个文件被更改,包括 11 次插入9 次删除
  1. 1 1
      packages/ckeditor5-watchdog/src/contextwatchdog.js
  2. 10 8
      packages/ckeditor5-watchdog/src/editorwatchdog.js

+ 1 - 1
packages/ckeditor5-watchdog/src/contextwatchdog.js

@@ -114,7 +114,7 @@ export default class ContextWatchdog extends Watchdog {
 			throw new Error( `Item with the given name was not registered: ${ itemName }.` );
 		}
 
-		return watchdog[ watchdog.constructor.instanceType ];
+		return watchdog._instance;
 	}
 
 	/**

+ 10 - 8
packages/ckeditor5-watchdog/src/editorwatchdog.js

@@ -22,13 +22,6 @@ import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
  */
 export default class EditorWatchdog extends Watchdog {
 	/**
-	 * Returns the instance type of the watchdog.
-	 */
-	static get instanceType() {
-		return 'editor';
-	}
-
-	/**
 	 * @param {module:watchdog/editorwatchdog~EditorWatchdogConfig} [config] The watchdog plugin configuration.
 	 */
 	constructor( config = {} ) {
@@ -96,6 +89,15 @@ export default class EditorWatchdog extends Watchdog {
 	}
 
 	/**
+	 * Returns the handled instance.
+	 *
+	 * @protected
+	 */
+	get _instance() {
+		return this._editor;
+	}
+
+	/**
 	 * Sets the function that is responsible for the editor creation.
 	 * It expects a function that should return a promise.
 	 *
@@ -128,7 +130,7 @@ export default class EditorWatchdog extends Watchdog {
 	 * Restarts the editor instance. This method is called whenever an editor error occurs. It fires the `restart` event and changes
 	 * the state to `initializing`.
 	 *
-	 * @public
+	 * @protected
 	 * @fires restart
 	 * @returns {Promise}
 	 */