Selaa lähdekoodia

Tests: Expanded a test in DocumentSelection.
Docs: Minor changes.

Szymon Cofalik 8 vuotta sitten
vanhempi
sitoutus
6015a62ac9

+ 4 - 4
packages/ckeditor5-engine/src/model/documentselection.js

@@ -678,8 +678,8 @@ export default class DocumentSelection extends Selection {
  */
 
 // Helper function for {@link module:engine/model/documentselection~DocumentSelection#_updateAttributes}.
-// It takes model item, checks whether
-// it is a text node (or text proxy) and if so, returns it's attributes. If not, returns `null`.
+//
+// It takes model item, checks whether it is a text node (or text proxy) and, if so, returns it's attributes. If not, returns `null`.
 //
 // @param {module:engine/model/item~Item|null}  node
 // @returns {Boolean}
@@ -691,7 +691,7 @@ function getAttrsIfCharacter( node ) {
 	return null;
 }
 
-// Removes selection attributes from element which is not anymore empty.
+// Removes selection attributes from element which is not empty anymore.
 function clearAttributesStoredInElement( changes, batch ) {
 	// Batch may not be passed to the document#change event in some tests.
 	// See https://github.com/ckeditor/ckeditor5-engine/issues/1001#issuecomment-314202352
@@ -702,7 +702,7 @@ function clearAttributesStoredInElement( changes, batch ) {
 
 	const changeParent = changes.range && changes.range.start.parent;
 
-	// changes.range is not set in case of rename, root and marker operations.
+	// `changes.range` is not set in case of rename, root and marker operations.
 	// None of them may lead to the element becoming non-empty.
 	if ( !changeParent || changeParent.isEmpty ) {
 		return;

+ 3 - 2
packages/ckeditor5-engine/tests/model/documentselection.js

@@ -997,14 +997,15 @@ describe( 'DocumentSelection', () => {
 				expect( emptyP.parent ).to.equal( root ); // Just to be sure we're checking the right element.
 			} );
 
-			it( 'are not removed when containing element is merged with another empty element', () => {
+			it( 'are not removed or merged when containing element is merged with another empty element', () => {
 				const emptyP2 = new Element( 'p', null );
 				root.appendChildren( emptyP2 );
 
 				emptyP.setAttribute( fooStoreAttrKey, 'bar' );
-				emptyP2.setAttribute( fooStoreAttrKey, 'bar' );
+				emptyP2.setAttribute( abcStoreAttrKey, 'bar' );
 
 				expect( emptyP.hasAttribute( fooStoreAttrKey ) ).to.be.true;
+				expect( emptyP.hasAttribute( abcStoreAttrKey ) ).to.be.false;
 
 				// <emptyP>{}<emptyP2>
 				doc.batch().merge( Position.createAfter( emptyP ) );