Explorar o código

Default parameter value for element.removeChildren.

Szymon Kupś %!s(int64=9) %!d(string=hai) anos
pai
achega
427f76ad96

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

@@ -126,7 +126,7 @@ export default class Element extends Node {
 	 * @returns {core.treeModel.NodeList} The list of removed nodes.
 	 */
 	removeChildren( index, number ) {
-		if ( !number ) {
+		if ( typeof number === 'undefined' ) {
 			number = 1;
 		}
 

+ 4 - 4
packages/ckeditor5-engine/src/treeview/element.js

@@ -69,7 +69,7 @@ export default class Element extends Node {
 		const childrenClone = [];
 
 		if ( deep ) {
-			for ( child of this.getChildren() ) {
+			for ( let child of this.getChildren() ) {
 				childrenClone.push( child.cloneNode( deep ) );
 			}
 		}
@@ -215,7 +215,7 @@ export default class Element extends Node {
 	removeChildren( index, number ) {
 		this._fireChange( 'CHILDREN', this );
 
-		if ( !number ) {
+		if ( typeof number === 'undefined' ) {
 			number = 1;
 		}
 
@@ -227,7 +227,7 @@ export default class Element extends Node {
 	}
 
 	same( otherNode ) {
-		if ( !otherNode instanceof Element ) {
+		if ( !( otherNode instanceof Element ) ) {
 			return false;
 		}
 
@@ -239,7 +239,7 @@ export default class Element extends Node {
 		const otherNodeAttrKeys = this.getAttributeKeys();
 		let count = 0;
 
-		for ( key of thisNodeAttrKeys ) {
+		for ( let key of thisNodeAttrKeys ) {
 			if ( this.getAttribute( key ) !== otherNode.getAttribute( key ) ) {
 				return false;
 			}