浏览代码

Fixed test in view renderer.

Szymon Kupś 9 年之前
父节点
当前提交
3d797108ca
共有 2 个文件被更改,包括 25 次插入22 次删除
  1. 4 2
      packages/ckeditor5-engine/src/view/renderer.js
  2. 21 20
      packages/ckeditor5-engine/tests/view/renderer.js

+ 4 - 2
packages/ckeditor5-engine/src/view/renderer.js

@@ -15,6 +15,8 @@ import remove from '../../utils/dom/remove.js';
 import ObservableMixin from '../../utils/observablemixin.js';
 import CKEditorError from '../../utils/ckeditorerror.js';
 
+/* global Range */
+
 /**
  * Renderer updates DOM structure and selection, to make them a reflection of the view structure and selection.
  *
@@ -472,8 +474,8 @@ export default class Renderer {
 		// Update contents.
 		const content = this.selection.fakeSelectionLabel || ' ';
 
-		if ( content !== this._fakeSelectionContainer.textContent ) {
-			this._fakeSelectionContainer.textContent = content;
+		if ( content !== this._fakeSelectionContainer.innerHTML ) {
+			this._fakeSelectionContainer.innerHTML = content;
 		}
 
 		// Update selection.

+ 21 - 20
packages/ckeditor5-engine/tests/view/renderer.js

@@ -1009,14 +1009,14 @@ describe( 'Renderer', () => {
 				expect( domRoot.childNodes.length ).to.equal( 2 );
 				const container = domRoot.childNodes[ 1 ];
 				expect( domConverter.getCorrespondingViewElement( container ) ).to.be.undefined;
-				expect( container.textContent ).to.equal( label );
+				expect( container.childNodes.length ).to.equal( 1 );
+				const textNode = container.childNodes[ 0 ];
+				expect( textNode.textContent ).to.equal( label );
 				const domSelection = domRoot.ownerDocument.getSelection();
-				expect( domSelection.rangeCount ).to.equal( 1 );
-				const domRange = domSelection.getRangeAt( 0 );
-				expect( domRange.startContainer ).to.equal( container );
-				expect( domRange.startOffset ).to.equal( 0 );
-				expect( domRange.endContainer ).to.equal( container );
-				expect( domRange.endOffset ).to.equal( 1 );
+				expect( domSelection.anchorNode ).to.equal( textNode );
+				expect( domSelection.anchorOffset ).to.equal( 0 );
+				expect( domSelection.focusNode ).to.equal( textNode );
+				expect( domSelection.focusOffset ).to.equal( label.length );
 			} );
 
 			it( 'should render   if no selection label is provided', () => {
@@ -1025,14 +1025,14 @@ describe( 'Renderer', () => {
 
 				expect( domRoot.childNodes.length ).to.equal( 2 );
 				const container = domRoot.childNodes[ 1 ];
-				expect( container.textContent ).to.equal( ' ' );
+				expect( container.childNodes.length ).to.equal( 1 );
+				const textNode = container.childNodes[ 0 ];
+				expect( container.innerHTML ).to.equal( ' ' );
 				const domSelection = domRoot.ownerDocument.getSelection();
-				expect( domSelection.rangeCount ).to.equal( 1 );
-				const domRange = domSelection.getRangeAt( 0 );
-				expect( domRange.startContainer ).to.equal( container );
-				expect( domRange.startOffset ).to.equal( 0 );
-				expect( domRange.endContainer ).to.equal( container );
-				expect( domRange.endOffset ).to.equal( 1 );
+				expect( domSelection.anchorNode ).to.equal( textNode );
+				expect( domSelection.anchorOffset ).to.equal( 0 );
+				expect( domSelection.focusNode ).to.equal( textNode );
+				expect( domSelection.focusOffset ).to.equal( 1 );
 			} );
 
 			it( 'should remove fake selection container when selection is no longer fake', () => {
@@ -1044,14 +1044,15 @@ describe( 'Renderer', () => {
 
 				expect( domRoot.childNodes.length ).to.equal( 1 );
 				const domParagraph = domRoot.childNodes[ 0 ];
+				expect( domParagraph.childNodes.length ).to.equal( 1 );
+				const textNode = domParagraph.childNodes[ 0 ];
 				expect( domParagraph.tagName.toLowerCase() ).to.equal( 'p' );
 				const domSelection = domRoot.ownerDocument.getSelection();
-				expect( domSelection.rangeCount ).to.equal( 1 );
-				const domRange = domSelection.getRangeAt( 0 );
-				expect( domRange.startContainer ).to.equal( domParagraph );
-				expect( domRange.startOffset ).to.equal( 0 );
-				expect( domRange.endContainer ).to.equal( domParagraph );
-				expect( domRange.endOffset ).to.equal( 1 );
+
+				expect( domSelection.anchorNode ).to.equal( textNode );
+				expect( domSelection.anchorOffset ).to.equal( 0 );
+				expect( domSelection.focusNode ).to.equal( textNode );
+				expect( domSelection.focusOffset ).to.equal( 7 );
 			} );
 
 			it( 'should reuse fake selection container #1', () => {