8
0
فهرست منبع

Internal: PendingActions#isPending was renamed to #hasAny. Closes ckeditor/ckeditor5-core#142.

Piotrek Koszuliński 7 سال پیش
والد
کامیت
88e2c4adc5

+ 4 - 4
packages/ckeditor5-core/src/pendingactions.js

@@ -69,9 +69,9 @@ export default class PendingActions extends Plugin {
 		 *
 		 * @readonly
 		 * @observable
-		 * @member {Boolean} #isPending
+		 * @member {Boolean} #hasAny
 		 */
-		this.set( 'isPending', false );
+		this.set( 'hasAny', false );
 
 		/**
 		 * A list of pending actions.
@@ -106,7 +106,7 @@ export default class PendingActions extends Plugin {
 
 		action.set( 'message', message );
 		this._actions.add( action );
-		this.isPending = true;
+		this.hasAny = true;
 
 		return action;
 	}
@@ -118,7 +118,7 @@ export default class PendingActions extends Plugin {
 	 */
 	remove( action ) {
 		this._actions.remove( action );
-		this.isPending = !!this._actions.length;
+		this.hasAny = !!this._actions.length;
 	}
 
 	/**

+ 1 - 1
packages/ckeditor5-core/tests/manual/pendingactions.js

@@ -44,7 +44,7 @@ ClassicEditor
 		} );
 
 		window.addEventListener( 'beforeunload', evt => {
-			if ( pendingActions.isPending ) {
+			if ( pendingActions.hasAny ) {
 				evt.returnValue = pendingActions.first.message;
 			}
 		} );

+ 10 - 10
packages/ckeditor5-core/tests/pendingactions.js

@@ -28,14 +28,14 @@ describe( 'PendingActions', () => {
 	} );
 
 	describe( 'init()', () => {
-		it( 'should have isPending observable', () => {
+		it( 'should have hasAny observable', () => {
 			const spy = sinon.spy();
 
-			pendingActions.on( 'change:isPending', spy );
+			pendingActions.on( 'change:hasAny', spy );
 
-			expect( pendingActions ).to.have.property( 'isPending', false );
+			expect( pendingActions ).to.have.property( 'hasAny', false );
 
-			pendingActions.isPending = true;
+			pendingActions.hasAny = true;
 
 			sinon.assert.calledOnce( spy );
 		} );
@@ -60,12 +60,12 @@ describe( 'PendingActions', () => {
 			sinon.assert.calledOnce( spy );
 		} );
 
-		it( 'should update isPending observable', () => {
-			expect( pendingActions ).to.have.property( 'isPending', false );
+		it( 'should update hasAny observable', () => {
+			expect( pendingActions ).to.have.property( 'hasAny', false );
 
 			pendingActions.add( 'Action' );
 
-			expect( pendingActions ).to.have.property( 'isPending', true );
+			expect( pendingActions ).to.have.property( 'hasAny', true );
 		} );
 
 		it( 'should throw an error when invalid message is given', () => {
@@ -90,15 +90,15 @@ describe( 'PendingActions', () => {
 			const action1 = pendingActions.add( 'Action 1' );
 			const action2 = pendingActions.add( 'Action 2' );
 
-			expect( pendingActions ).to.have.property( 'isPending', true );
+			expect( pendingActions ).to.have.property( 'hasAny', true );
 
 			pendingActions.remove( action1 );
 
-			expect( pendingActions ).to.have.property( 'isPending', true );
+			expect( pendingActions ).to.have.property( 'hasAny', true );
 
 			pendingActions.remove( action2 );
 
-			expect( pendingActions ).to.have.property( 'isPending', false );
+			expect( pendingActions ).to.have.property( 'hasAny', false );
 		} );
 
 		it( 'should fire remove event with removed item', () => {