瀏覽代碼

Remove is() method from unnecessary model's classes.

Mateusz Samsel 6 年之前
父節點
當前提交
47ddc2d89d

+ 0 - 12
packages/ckeditor5-engine/src/model/batch.js

@@ -79,16 +79,4 @@ export default class Batch {
 
 		return operation;
 	}
-
-	/**
-	 * Checks whether given object is of `batch` type.
-	 *
-	 * Read more at {@link module:engine/model/model~Model#is `Model#is()`}.
-	 *
-	 * @param {String} type
-	 * @returns {Boolean}
-	 */
-	is( type ) {
-		return type == 'batch' || type == 'model:batch';
-	}
 }

+ 0 - 12
packages/ckeditor5-engine/src/model/differ.js

@@ -520,18 +520,6 @@ export default class Differ {
 	}
 
 	/**
-	 * Checks whether given object is of `differ` type.
-	 *
-	 * Read more at {@link module:engine/model/model~Model#is `Model#is()`}.
-	 *
-	 * @param {String} type
-	 * @returns {Boolean}
-	 */
-	is( type ) {
-		return type == 'differ' || type == 'model:differ';
-	}
-
-	/**
 	 * Resets `Differ`. Removes all buffered changes.
 	 */
 	reset() {

+ 0 - 12
packages/ckeditor5-engine/src/model/document.js

@@ -242,18 +242,6 @@ export default class Document {
 	}
 
 	/**
-	 * Checks whether given object is of `document` type.
-	 *
-	 * Read more at {@link module:engine/model/model~Model#is `Model#is()`}.
-	 *
-	 * @param {String} type
-	 * @returns {Boolean}
-	 */
-	is( type ) {
-		return type == 'document' || type == 'model:document';
-	}
-
-	/**
 	 * Used to register a post-fixer callback. A post-fixer mechanism guarantees that the features
 	 * will operate on a correct model state.
 	 *

+ 1 - 1
packages/ckeditor5-engine/src/model/documentfragment.js

@@ -118,7 +118,7 @@ export default class DocumentFragment {
 	/**
 	 * Checks whether given model tree object is of given type.
 	 *
-	 * Read more in {@link module:engine/model/node~Node#is `Node#is()`} and {@link module:engine/model/model~Model#is `Model#is()`}.
+	 * Read more in {@link module:engine/model/node~Node#is `Node#is()`}.
 	 *
 	 * @param {String} type
 	 * @returns {Boolean}

+ 0 - 2
packages/ckeditor5-engine/src/model/documentselection.js

@@ -382,8 +382,6 @@ export default class DocumentSelection {
 	 *		selection.is( 'model:node' ); // false
 	 *		selection.is( 'element' ); // false
 	 *
-	 * Read more at {@link module:engine/model/model~Model#is `Model#is()`}.
-	 *
 	 * @param {String} type
 	 * @returns {Boolean}
 	 */

+ 1 - 1
packages/ckeditor5-engine/src/model/element.js

@@ -105,7 +105,7 @@ export default class Element extends Node {
 	 *		obj.is( 'view:element' ); // false
 	 *		obj.is( 'element', 'image' ); // false
 	 *
-	 * Read more in {@link module:engine/model/node~Node#is `Node#is()`} and {@link module:engine/model/model~Model#is `Model#is()`}.
+	 * Read more in {@link module:engine/model/node~Node#is `Node#is()`}.
 	 *
 	 * @param {String} type Type to check when `name` parameter is present.
 	 * Otherwise, it acts like the `name` parameter.

+ 0 - 12
packages/ckeditor5-engine/src/model/history.js

@@ -98,18 +98,6 @@ export default class History {
 	}
 
 	/**
-	 * Checks whether given object is of `history` type.
-	 *
-	 * Read more at {@link module:engine/model/model~Model#is `Model#is()`}.
-	 *
-	 * @param {String} type
-	 * @returns {Boolean}
-	 */
-	is( type ) {
-		return type == 'history' || type == 'model:history';
-	}
-
-	/**
 	 * Checks whether given `operation` is undoing any other operation.
 	 *
 	 * @param {module:engine/model/operation/operation~Operation} operation Operation to check.

+ 1 - 13
packages/ckeditor5-engine/src/model/markercollection.js

@@ -73,18 +73,6 @@ export default class MarkerCollection {
 	}
 
 	/**
-	 * Checks whether given object is of `markerCollection` type.
-	 *
-	 * Read more at {@link module:engine/model/model~Model#is `Model#is()`}.
-	 *
-	 * @param {String} type
-	 * @returns {Boolean}
-	 */
-	is( type ) {
-		return type == 'markerCollection' || type == 'model:markerCollection';
-	}
-
-	/**
 	 * Creates and adds a {@link ~Marker marker} to the `MarkerCollection` with given name on given
 	 * {@link module:engine/model/range~Range range}.
 	 *
@@ -463,7 +451,7 @@ class Marker {
 	/**
 	 * Checks whether given object is of `marker` type.
 	 *
-	 * Read more at {@link module:engine/model/model~Model#is}.
+	 * Read more at {@link module:engine/model/model~Node#is}.
 	 *
 	 * @param {String} type
 	 * @returns {Boolean}

+ 0 - 36
packages/ckeditor5-engine/src/model/model.js

@@ -718,42 +718,6 @@ export default class Model {
 	}
 
 	/**
-	 * Checks whether given object is of `model` type.
-	 *
-	 * All classes related to {@link module:engine/model/model~Model} might contain `is` method,
-	 * which checks if given object belong to specific type. Types are defined as name of the class
-	 * written in [camelCase](https://en.wikipedia.org/wiki/Camel_case) notation. E.g. class `LiveRange`
-	 * will get type `liveRange`. There might appear some additional possibilities to test types which will be described in
-	 * related documentation.
-	 *
-	 * Method might simplify your code for cases, when you want to test unknown object for specific type.
-	 * Instead of using `instanceof` and importing entire class for testing, there might be used `is` method which test for given name.
-	 * There is also available `model:` prefix in each case, which gives more specific results.
-	 * It helps to distinguish model's classes from view's. Few examples how to use this method you can find below:
-	 *
-	 * 	const model = new Model();
-	 * 	model.is( 'model' ) // return true
-	 *
-	 * 	const range = new LiveRange( startPosition )
-	 * 	range.is( 'range' ) // return true
-	 * 	range.is( 'liveRange' ) // return true
-	 * 	range.is( 'model:range' ) // return true
-	 * 	range.is( 'model:liveRange' ) // return true
-	 * 	range.is( 'view:range' ) // return false
-	 *
-	 * 	const document = new Document();
-	 * 	document.is( 'model:document' ) // return true
-	 *
-	 * See also {@link module:engine/model/node~Node#is `Node#is()`} for some more details related to elements.
-	 *
-	 * @param {String} type
-	 * @returns {Boolean}
-	 */
-	is( type ) {
-		return type == 'model';
-	}
-
-	/**
 	 * Common part of {@link module:engine/model/model~Model#change} and {@link module:engine/model/model~Model#enqueueChange}
 	 * which calls callbacks and returns array of values returned by these callbacks.
 	 *

+ 4 - 2
packages/ckeditor5-engine/src/model/node.js

@@ -469,6 +469,10 @@ export default class Node {
 	 * that can be either text node or element. This method can be used to check what kind of object is returned.
 	 * All checked types might be prefixed with `model:` to narrow search exclusively to model's objects.
 	 * That should prevent of situation where `view:node` accidentally might be considered as `model:node`.
+	 * Types are defined as name of the class written in [camelCase](https://en.wikipedia.org/wiki/Camel_case) notation.
+	 * E.g. class `LiveRange` will get type `liveRange`.
+	 *
+	 * There is more classes in model which follows similar naming convention. Check corresponding elements documentation for more details.
 	 *
 	 *		obj.is( 'node' ); // true for any node, false for document fragment and text fragment
 	 *		obj.is( 'documentFragment' ); // true for document fragment, false for any node
@@ -478,8 +482,6 @@ export default class Node {
 	 *		obj.is( 'text' ); // true for text node, false for element and document fragment
 	 *		obj.is( 'textProxy' ); // true for text proxy object
 	 *
-	 *	Read more at {@link module:engine/model/model~Model#is `Model#is()`}.
-	 *
 	 * @method #is
 	 * @param {String} type
 	 * @returns {Boolean}

+ 0 - 12
packages/ckeditor5-engine/src/model/nodelist.js

@@ -171,18 +171,6 @@ export default class NodeList {
 	}
 
 	/**
-	 * Checks whether given object is of `nodeList` type.
-	 *
-	 * Read more at {@link module:engine/model/model~Model#is `Model#is()`}.
-	 *
-	 * @param {String} type
-	 * @returns {Boolean}
-	 */
-	is( type ) {
-		return type == 'nodeList' || type == 'model:nodeList';
-	}
-
-	/**
 	 * Inserts given nodes at given index.
 	 *
 	 * @protected

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

@@ -505,7 +505,7 @@ export default class Position {
 	/**
 	 * Checks whether given object is of `position` type.
 	 *
-	 * Read more at {@link module:engine/model/model~Model#is `Model#is()`}.
+	 * Read more at {@link module:engine/model/model~Node#is `Node#is()`}.
 	 *
 	 * @param {String} type
 	 * @returns {Boolean}

+ 1 - 1
packages/ckeditor5-engine/src/model/range.js

@@ -146,7 +146,7 @@ export default class Range {
 	/**
 	 * Checks whether given object is of `range` type.
 	 *
-	 * Read more at {@link module:engine/model/model~Model#is `Model#is()`}.
+	 * Read more at {@link module:engine/model/model~Node#is `Node#is()`}.
 	 *
 	 * @param {String} type
 	 * @returns {Boolean}

+ 0 - 12
packages/ckeditor5-engine/src/model/schema.js

@@ -188,18 +188,6 @@ export default class Schema {
 	}
 
 	/**
-	 * Checks whether given object is of `schema` type.
-	 *
-	 * Read more at {@link module:engine/model/model~Model#is `Model#is()`}.
-	 *
-	 * @param {String} type
-	 * @returns {Boolean}
-	 */
-	is( type ) {
-		return type == 'schema' || type == 'model:schema';
-	}
-
-	/**
 	 * Returns `true` if the given item is registered in the schema.
 	 *
 	 *		schema.isRegistered( 'paragraph' ); // -> true

+ 0 - 2
packages/ckeditor5-engine/src/model/selection.js

@@ -634,8 +634,6 @@ export default class Selection {
 	 *		selection.is( 'element' ); // false
 	 *		selection.is( 'view:selection' ); // false
 	 *
-	 * Read more at {@link module:engine/model/model~Model#is `Model#is()`}.
-	 *
 	 * @param {String} type
 	 * @returns {Boolean}
 	 */

+ 1 - 1
packages/ckeditor5-engine/src/model/textproxy.js

@@ -175,7 +175,7 @@ export default class TextProxy {
 	/**
 	 * Checks whether given object is of `textProxy` type.
 	 *
-	 * Read more in {@link module:engine/model/node~Node#is `Node#is()`} and {@link module:engine/model/model~Model#is `Model#is()`}.
+	 * Read more in {@link module:engine/model/node~Node#is `Node#is()`}.
 	 *
 	 * @param {String} type
 	 * @returns {Boolean}

+ 0 - 12
packages/ckeditor5-engine/src/model/treewalker.js

@@ -153,18 +153,6 @@ export default class TreeWalker {
 	}
 
 	/**
-	 * Checks whether given object is of `treeWalker` type.
-	 *
-	 * Read more at {@link module:engine/model/model~Model#is `Model#is()`}.
-	 *
-	 * @param {String} type
-	 * @returns {Boolean}
-	 */
-	is( type ) {
-		return type == 'treeWalker' || type == 'model:treeWalker';
-	}
-
-	/**
 	 * Iterable interface.
 	 *
 	 * @returns {Iterable.<module:engine/model/treewalker~TreeWalkerValue>}

+ 0 - 12
packages/ckeditor5-engine/src/model/writer.js

@@ -80,18 +80,6 @@ export default class Writer {
 	}
 
 	/**
-	 * Checks whether given object is of `writer` type.
-	 *
-	 * Read more at {@link module:engine/model/model~Model#is `Model#is()`}.
-	 *
-	 * @param {String} type
-	 * @returns {Boolean}
-	 */
-	is( type ) {
-		return type == 'writer' || type == 'model:writer';
-	}
-
-	/**
 	 * Creates a new {@link module:engine/model/text~Text text node}.
 	 *
 	 *		writer.createText( 'foo' );