8
0
Просмотр исходного кода

Fixed issue on Edge with not updating input text value when attribute is removed.

Szymon Kupś 8 лет назад
Родитель
Сommit
3e11012943

+ 20 - 2
packages/ckeditor5-ui/src/inputtext/inputtextview.js

@@ -67,12 +67,30 @@ export default class InputTextView extends View {
 				],
 				id: bind.to( 'id' ),
 				placeholder: bind.to( 'placeholder' ),
-				readonly: bind.to( 'isReadOnly' ),
-				value: bind.to( 'value' )
+				readonly: bind.to( 'isReadOnly' )
 			}
 		} );
 	}
 
+	/**
+	 * @inheritDoc
+	 */
+	render() {
+		super.render();
+
+		const setValue = value => {
+			this.element.value = ( !value && value !== 0 ) ? '' : value;
+		};
+
+		setValue( this.value );
+
+		// Bind `this.value` to the DOM element's value.
+		// We cannot use `value` DOM attribute because removing it on Edge does not clear the DOM element's value property.
+		this.on( 'change:value', ( evt, name, value ) => {
+			setValue( value );
+		} );
+	}
+
 	/**
 	 * Moves the focus to the input and selects the value.
 	 */

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

@@ -14,6 +14,10 @@ describe( 'InputTextView', () => {
 		view.render();
 	} );
 
+	afterEach( () => {
+		view.destroy();
+	} );
+
 	describe( 'constructor()', () => {
 		it( 'should creates element from template', () => {
 			expect( view.element.tagName ).to.equal( 'INPUT' );