Browse Source

Feature: Implemented placeholder in InputTextView. Closes #220.

Aleksander Nowodzinski 8 years ago
parent
commit
ebd289cbea

+ 10 - 1
packages/ckeditor5-ui/src/inputtext/inputtextview.js

@@ -38,6 +38,14 @@ export default class InputTextView extends View {
 		 */
 		this.set( 'id' );
 
+		/**
+		 * The `placeholder` attribute of the input.
+		 *
+		 * @observable
+		 * @member {String} #placeholder
+		 */
+		this.set( 'placeholder' );
+
 		const bind = this.bindTemplate;
 
 		this.template = new Template( {
@@ -48,7 +56,8 @@ export default class InputTextView extends View {
 					'ck-input',
 					'ck-input-text'
 				],
-				id: bind.to( 'id' )
+				id: bind.to( 'id' ),
+				placeholder: bind.to( 'placeholder' )
 			}
 		} );
 

+ 10 - 0
packages/ckeditor5-ui/tests/inputtext/inputtextview.js

@@ -56,6 +56,16 @@ describe( 'InputTextView', () => {
 				expect( view.element.id ).to.equal( 'baz' );
 			} );
 		} );
+
+		describe( 'placeholder', () => {
+			it( 'should react on view#placeholder', () => {
+				expect( view.element.placeholder ).to.equal( '' );
+
+				view.placeholder = 'baz';
+
+				expect( view.element.placeholder ).to.equal( 'baz' );
+			} );
+		} );
 	} );
 
 	describe( 'select()', () => {