Explorar el Código

Tests, Docs: Improved grammar and wording in the tests' descriptions and code comments.

Aleksander Nowodzinski hace 8 años
padre
commit
ae276fe2e6

+ 6 - 5
packages/ckeditor5-core/src/editor/standardeditor.js

@@ -115,14 +115,14 @@ export default class StandardEditor extends Editor {
 	_attachToForm() {
 		const element = this.element;
 
-		// When replacing textarea which is inside form element.
+		// Only when replacing a textarea which is inside of a form element.
 		if ( element && element.tagName.toLowerCase() === 'textarea' && element.form ) {
 			let originalSubmit;
 			const form = element.form;
 			const onSubmit = () => this.updateEditorElement();
 
-			// Replace original submit() method on a form to call our submit function before.
-			// Check if it is a function because it might contain an input with "submit" name.
+			// Replace the original form#submit() to call a custom submit function first.
+			// Check if #submit is a function because the form might have an input named "submit".
 			if ( isFunction( form.submit ) ) {
 				originalSubmit = form.submit;
 
@@ -132,10 +132,11 @@ export default class StandardEditor extends Editor {
 				};
 			}
 
-			// Update replaced textarea with data before each submit.
+			// Update the replaced textarea with data before each form#submit event.
 			form.addEventListener( 'submit', onSubmit );
 
-			// Remove submit listener, and reset original submit method on editor destroy.
+			// Remove the submit listener and revert the original submit method on
+			// editor#destroy.
 			this.on( 'destroy', () => {
 				form.removeEventListener( 'submit', onSubmit );
 

+ 8 - 8
packages/ckeditor5-core/tests/editor/standardeditor.js

@@ -233,7 +233,7 @@ describe( 'StandardEditor', () => {
 			form.remove();
 		} );
 
-		it( 'should update editor element contents after calling submit() method', () => {
+		it( 'should update editor#element after calling the submit() method', () => {
 			return createEditor( textarea )
 				.then( editor => {
 					expect( textarea.value ).to.equal( '' );
@@ -246,13 +246,13 @@ describe( 'StandardEditor', () => {
 					sinon.assert.calledOnce( submitStub );
 
 					// Check if original function was called in correct context.
-					expect( submitStub.firstCall.thisValue ).to.equal( form );
+					sinon.assert.calledOn( submitStub, form );
 
 					return editor.destroy();
 				} );
 		} );
 
-		it( 'should update editor element contents after "submit" event', () => {
+		it( 'should update editor#element after the "submit" event', () => {
 			return createEditor( textarea )
 				.then( editor => {
 					expect( textarea.value ).to.equal( '' );
@@ -265,7 +265,7 @@ describe( 'StandardEditor', () => {
 				} );
 		} );
 
-		it( 'should not update element in form which is not a textarea', () => {
+		it( 'should not update editor#element if it is not a textarea in a form', () => {
 			const element = document.createElement( 'div' );
 			form.appendChild( element );
 
@@ -286,7 +286,7 @@ describe( 'StandardEditor', () => {
 				} );
 		} );
 
-		it( 'should not update textarea which is outside a form', () => {
+		it( 'should not update editor#element not belonging to a form', () => {
 			const textarea = document.createElement( 'textarea' );
 			document.body.appendChild( textarea );
 
@@ -307,7 +307,7 @@ describe( 'StandardEditor', () => {
 				} );
 		} );
 
-		it( 'should not update element after destroying the editor - form.submit()', () => {
+		it( 'should not update editor#element after destruction of the editor - form.submit()', () => {
 			return createEditor( textarea )
 				.then( editor => editor.destroy() )
 				.then( () => {
@@ -321,7 +321,7 @@ describe( 'StandardEditor', () => {
 				} );
 		} );
 
-		it( 'should not update element after destroying the editor - "submit" event', () => {
+		it( 'should not update the editor#element after destruction of the editor - "submit" event', () => {
 			return createEditor( textarea )
 				.then( editor => editor.destroy() )
 				.then( () => {
@@ -333,7 +333,7 @@ describe( 'StandardEditor', () => {
 				} );
 		} );
 
-		it( 'should not replace submit() method when one of the elements in form has "submit" name', () => {
+		it( 'should not replace submit() method when one of the elements in a form is named "submit"', () => {
 			const input = document.createElement( 'input' );
 			input.setAttribute( 'name', 'submit' );
 			form.appendChild( input );