| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- /**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
- /**
- * @module engine/model/rootelement
- */
- import Element from './element';
- /**
- * Type of {@link module:engine/model/element~Element} that is a root of a model tree.
- * @extends module:engine/model/element~Element
- */
- export default class RootElement extends Element {
- /**
- * Creates root element.
- *
- * @param {module:engine/model/document~Document} doc Document that is an owner of this root.
- * @param {String} name Node name.
- * @param {String} [rootName='main'] Unique root name used to identify this root element by {@link module:engine/model/document~Document}.
- */
- constructor( doc, name, rootName = 'main' ) {
- super( name );
- /**
- * Document that is an owner of this root.
- *
- * @private
- * @member {module:engine/model/document~Document}
- */
- this._doc = doc;
- /**
- * Unique root name used to identify this root element by {@link module:engine/model/document~Document}.
- *
- * @readonly
- * @member {String}
- */
- this.rootName = rootName;
- }
- /**
- * {@link module:engine/model/document~Document Document} that owns this root element.
- *
- * In contrary, to {@link module:engine/model/node~Node node}, root element always have a `document`.
- *
- * @readonly
- * @type {module:engine/model/document~Document|null}
- */
- get document() {
- return this._doc;
- }
- /**
- * Converts `RootElement` instance to `String` containing it's name.
- *
- * @returns {String} `RootElement` instance converted to `String`.
- */
- toJSON() {
- return this.rootName;
- }
- }
|