ソースを参照

Simplified checking of nodes valid to insert.

Oskar Wróbel 9 年 前
コミット
f693874096
1 ファイル変更6 行追加7 行削除
  1. 6 7
      packages/ckeditor5-engine/src/view/writer.js

+ 6 - 7
packages/ckeditor5-engine/src/view/writer.js

@@ -1211,16 +1211,15 @@ function rangeSpansOnAllChildren( range ) {
 // @param Iterable.<module:engine/view/text~Text|module:engine/view/attributeelement~AttributeElement
 // |module:engine/view/containerelement~ContainerElement> nodes
 function validateNodesToInsert( nodes ) {
+	const validNodes = [ Text, AttributeElement, ContainerElement, EmptyElement, UIElement ];
+
 	for ( let node of nodes ) {
-		if (
-			!( node instanceof Text || node instanceof AttributeElement || node instanceof ContainerElement ||
-			node instanceof EmptyElement || node instanceof UIElement )
-		) {
+		if ( !validNodes.some( ( validNode => node instanceof validNode ) ) ) {
 			/**
-			 * Inserted nodes should be instance of {@link module:engine/view/attributeelement~AttributeElement AttributeElement},
+			 * Inserted nodes should be valid to insert. of {@link module:engine/view/attributeelement~AttributeElement AttributeElement},
 			 * {@link module:engine/view/containerelement~ContainerElement ContainerElement},
-			 * {@link module:engine/view/emptyerelement~EmptyElement EmptyElement},
-			 * {@link module:engine/view/uierelement~UIElement UIElement}, {@link module:engine/view/text~Text Text}.
+			 * {@link module:engine/view/emptyelement~EmptyElement EmptyElement},
+			 * {@link module:engine/view/uielement~UIElement UIElement}, {@link module:engine/view/text~Text Text}.
 			 *
 			 * @error view-writer-insert-invalid-node
 			 */