8
0
Просмотр исходного кода

Add FocustTracker.destroy() method.

Maciej Gołaszewski 7 лет назад
Родитель
Сommit
594d6c3c80
1 измененных файлов с 10 добавлено и 0 удалено
  1. 10 0
      packages/ckeditor5-utils/src/focustracker.js

+ 10 - 0
packages/ckeditor5-utils/src/focustracker.js

@@ -94,6 +94,16 @@ export default class FocusTracker {
 		}
 	}
 
+	/**
+	 * Destroys the focus tracker by:
+	 * - Disabling all event listeners attached to tracked elements.
+	 * - Removing all tracked elements that were previously added.
+	 */
+	destroy() {
+		this.stopListening();
+		this._elements.clear();
+	}
+
 	/**
 	 * Stores currently focused element and set {#isFocused} as `true`.
 	 *