瀏覽代碼

Nodes list also accept iterables.

Piotr Jasiun 10 年之前
父節點
當前提交
4b9230ec1a

+ 2 - 2
packages/ckeditor5-utils/src/document/element.js

@@ -19,7 +19,7 @@ CKEDITOR.define( [ 'document/node', 'document/nodelist' ], function( Node, NodeL
 		 *
 		 * @param {String} name Node name.
 		 * @param {Iterable} attrs Iterable collection of {@link document.Attribute attributes}.
-		 * @param {document.Node|document.Text|document.NodeList|String|Array} nodes List of nodes to be inserted.
+		 * @param {document.Node|document.Text|document.NodeList|String|Iterable} nodes List of nodes to be inserted.
 		 * List of nodes can be any type accepted by the {@link document.NodeList} constructor.
 		 * @constructor
 		 */
@@ -54,7 +54,7 @@ CKEDITOR.define( [ 'document/node', 'document/nodelist' ], function( Node, NodeL
 		 * All attached nodes should be modified using the {@link document.InsertOperation}.
 		 *
 		 * @param {Nuber} index Position where nodes should be inserted.
-		 * @param {document.Node|document.Text|document.NodeList|String|Array} nodes List of nodes to be inserted.
+		 * @param {document.Node|document.Text|document.NodeList|String|Iterable} nodes List of nodes to be inserted.
 		 * List of nodes can be any type accepted by the {@link document.NodeList} constructor.
 		 */
 		insertChildren( index, nodes ) {

+ 1 - 1
packages/ckeditor5-utils/src/document/insertoperation.js

@@ -16,7 +16,7 @@ CKEDITOR.define( [ 'document/operation', 'document/nodelist', 'document/removeop
 		 * Creates an insert operation.
 		 *
 		 * @param {document.Position} position Position of insertion.
-		 * @param {document.Node|document.Text|document.NodeList|String|Array} nodes List of nodes to be inserted.
+		 * @param {document.Node|document.Text|document.NodeList|String|Iterable} nodes List of nodes to be inserted.
 		 * List of nodes can be any type accepted by the {@link document.NodeList} constructor.
 		 * @param {Number} baseVersion {@link document.Document#version} on which operation can be applied.
 		 * @constructor

+ 1 - 1
packages/ckeditor5-utils/src/document/moveoperation.js

@@ -27,7 +27,7 @@ CKEDITOR.define( [
 		 *
 		 * @param {document.Position} sourcePosition Source move position.
 		 * @param {document.Position} targetPosition Target move position.
-		 * @param {document.Node|document.Text|document.NodeList|String|Array} nodes List of nodes to be moved.
+		 * @param {document.Node|document.Text|document.NodeList|String|Iterable} nodes List of nodes to be moved.
 		 * List of nodes can be any type accepted by the {@link document.NodeList} constructor.
 		 * @param {Number} baseVersion {@link document.Document#version} on which operation can be applied.
 		 * @constructor

+ 6 - 6
packages/ckeditor5-utils/src/document/nodelist.js

@@ -50,7 +50,7 @@ CKEDITOR.define( [
 		 *		nodeListA === nodeListB // true
 		 *		nodeListB.length // 3
 		 *
-		 * @param {document.Node|document.Text|document.NodeList|String|Array} nodes List of nodes.
+		 * @param {document.Node|document.Text|document.NodeList|String|Iterable} nodes List of nodes.
 		 * @constructor
 		 */
 		constructor( nodes ) {
@@ -68,7 +68,7 @@ CKEDITOR.define( [
 			this._nodes = [];
 
 			if ( nodes ) {
-				var node, i, nodeLen;
+				var node, character;
 
 				if ( !utils.isIterable( nodes ) ) {
 					nodes = [ nodes ];
@@ -81,14 +81,14 @@ CKEDITOR.define( [
 					}
 					// Text.
 					else if ( node instanceof Text ) {
-						for ( i = 0, nodeLen = node.text.length; i < nodeLen; i++ ) {
-							this._nodes.push( new Character( node.text[ i ], node.attrs ) );
+						for ( character of node.text ) {
+							this._nodes.push( new Character( character, node.attrs ) );
 						}
 					}
 					// String.
 					else {
-						for ( i = 0, nodeLen = node.length; i < nodeLen; i++ ) {
-							this._nodes.push( new Character( node[ i ] ) );
+						for ( character of node ) {
+							this._nodes.push( new Character( character ) );
 						}
 					}
 				}

+ 1 - 1
packages/ckeditor5-utils/src/document/removeoperation.js

@@ -27,7 +27,7 @@ CKEDITOR.define( [
 		 * This is why this constructor contains list of nodes instead of length.
 		 *
 		 * @param {document.Position} position Position before the first node to remove.
-		 * @param {document.Node|document.Text|document.NodeList|String|Array} nodes List of nodes to be remove.
+		 * @param {document.Node|document.Text|document.NodeList|String|Iterable} nodes List of nodes to be remove.
 		 * List of nodes can be any type accepted by the {@link document.NodeList} constructor.
 		 * @param {Number} baseVersion {@link document.Document#version} on which operation can be applied.
 		 * @constructor