ソースを参照

Fixes: UndoFeature/UndoCommand changes Map/Set to WeakMap/WeakSet.

Szymon Cofalik 9 年 前
コミット
6f0ef8151e

+ 3 - 3
packages/ckeditor5-undo/src/undocommand.js

@@ -32,9 +32,9 @@ export default class UndoCommand extends Command {
 		 * Stores the selection ranges for each batch and use them to recreate selection after undo.
 		 *
 		 * @private
-		 * @member {Map.<engine.treeModel.Range>} undo.UndoCommand#_batchSelection
+		 * @member {WeakMap.<engine.treeModel.Range>} undo.UndoCommand#_batchSelection
 		 */
-		this._batchSelection = new Map();
+		this._batchSelection = new WeakMap();
 	}
 
 	/**
@@ -103,7 +103,7 @@ export default class UndoCommand extends Command {
 
 		// The ranges will be transformed by deltas from history that took place
 		// after the selection got stored.
-		const deltas = this.editor.document.history.getDeltas( undoBatch.deltas[ 0 ].baseVersion );
+		const deltas = this.editor.document.history.getDeltas( undoBatch.deltas[ 0 ].baseVersion ) || [];
 
 		// This will keep the transformed ranges.
 		const transformedRanges = [];

+ 2 - 2
packages/ckeditor5-undo/src/undofeature.js

@@ -39,9 +39,9 @@ export default class UndoFeature extends Feature {
 		 * Keeps track of which batch has already been added to undo manager.
 		 *
 		 * @private
-		 * @member {Set} undo.UndoFeature#_batchRegistry
+		 * @member {WeakSet.<engine.treeModel.Batch>} undo.UndoFeature#_batchRegistry
 		 */
-		this._batchRegistry = new Set();
+		this._batchRegistry = new WeakSet();
 	}
 
 	/**