8
0
Эх сурвалжийг харах

#396: Remove graveyard symbol in favor of '$graveyard' string.

Maciej Gołaszewski 9 жил өмнө
parent
commit
5cce07d1b7

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

@@ -20,7 +20,7 @@ import Schema from './schema.js';
 import Composer from './composer/composer.js';
 import clone from '../../utils/lib/lodash/clone.js';
 
-const graveyardSymbol = Symbol( 'graveyard' );
+const graveyardName = '$graveyard';
 
 /**
  * Document tree model describes all editable data in the editor. It may contain multiple
@@ -103,7 +103,7 @@ export default class Document {
 		} );
 
 		// Graveyard tree root. Document always have a graveyard root, which stores removed nodes.
-		this.createRoot( graveyardSymbol );
+		this.createRoot( graveyardName );
 
 		/**
 		 * Document's history.
@@ -121,7 +121,7 @@ export default class Document {
 	 * @type {engine.treeModel.RootElement}
 	 */
 	get graveyard() {
-		return this.getRoot( graveyardSymbol );
+		return this.getRoot( graveyardName );
 	}
 
 	/**
@@ -131,7 +131,7 @@ export default class Document {
 	 * @type {Iterable.<String>}
 	 */
 	get rootNames() {
-		return Array.from( this._roots.keys() ).filter( ( name ) => name != graveyardSymbol );
+		return Array.from( this._roots.keys() ).filter( ( name ) => name != graveyardName );
 	}
 
 	/**

+ 1 - 1
packages/ckeditor5-engine/src/treemodel/position.js

@@ -571,7 +571,7 @@ export default class Position {
 	 * @returns {engine.treeModel.Position}
 	 */
 	static fromJSON( json, doc ) {
-		if ( json.root === '$$graveyard' ) {
+		if ( json.root === '$graveyard' ) {
 			return new Position( doc.graveyard, json.path );
 		}
 

+ 1 - 1
packages/ckeditor5-engine/src/treemodel/rootelement.js

@@ -48,6 +48,6 @@ export default class RootElement extends Element {
 	 * @returns {String} Name of this root inside {@link engine.treeModel.Document} that is an owner of this root.
 	 */
 	toJSON() {
-		return typeof this.rootName === 'symbol' ? '$$graveyard' : this.rootName;
+		return this.rootName;
 	}
 }

+ 2 - 2
packages/ckeditor5-engine/tests/treemodel/position.js

@@ -697,7 +697,7 @@ describe( 'position', () => {
 
 			let serialized = jsonParseStringify( position );
 
-			expect( serialized ).to.deep.equal( { root: '$$graveyard', path: [ 0 ] } );
+			expect( serialized ).to.deep.equal( { root: '$graveyard', path: [ 0 ] } );
 		} );
 	} );
 
@@ -710,7 +710,7 @@ describe( 'position', () => {
 		} );
 
 		it( 'should create object from graveyard', () => {
-			let deserialized = Position.fromJSON( { root: '$$graveyard', path: [ 0, 1, 2 ] }, doc );
+			let deserialized = Position.fromJSON( { root: '$graveyard', path: [ 0, 1, 2 ] }, doc );
 
 			expect( deserialized.root ).to.equal( doc.graveyard );
 			expect( deserialized.path ).to.deep.equal( [ 0, 1, 2 ] );