Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

fix #288 placeholder not removed correctly after data model changes #302

Closed
wants to merge 1 commit into from

2 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
27 src/aria/html/TextInput.js
@@ -69,11 +69,7 @@
var specialKeys = [domevent.KC_END, domevent.KC_RIGHT, domevent.KC_ARROW_RIGHT, domevent.KC_DOWN,
domevent.KC_ARROW_DOWN, domevent.KC_DELETE, domevent.KC_BACKSPACE];
if (!aria.utils.Array.contains(specialKeys, event.keyCode)) {
- var cssClass = new aria.utils.ClassList(this._domElt);
- this._domElt.value = "";
- this._hasPlaceholder = false;
- cssClass.remove('placeholder');
- cssClass.$dispose();
+ this._removePlaceholder();
} else {
event.preventDefault();
}
@@ -255,7 +251,11 @@
*/
onbind : function (name, value, oldValue) {
if (name === "value") {
- this._domElt.value = (value != null) ? value : "";
+ value = (value != null) ? value + "" : "";
+ if (value) {
+ this._removePlaceholder()
+ }
+ this._domElt.value = value;
this._setPlaceholder();
}
},
@@ -339,6 +339,21 @@
},
/**
+ * Remove the css class and value for placeholder if needed by browsers that don't support it natively.
+ * @protected
+ */
+ _removePlaceholder : function () {
+ if (this._hasPlaceholder) {
+ var element = this._domElt;
+ var cssClass = new aria.utils.ClassList(element);
+ element.value = "";
+ this._hasPlaceholder = false;
+ cssClass.remove('placeholder');
+ cssClass.$dispose();
+ }
+ },
+
+ /**
* Add special listeners on top of the ones specified in configuration.
* @param {aria.html.beans.TextInputCfg.Properties} cfg Widget configuration.
* @param {aria.templates.TemplateCtxt} context Template context.
View
6 test/aria/html/textinput/placeholder/PlaceholderTestCase.js
@@ -209,10 +209,14 @@ Aria.classDefinition({
},
_testWhenDataChangeToNull : function () {
- aria.utils.Json.setValue(this.data, "arrival", "");
+ aria.utils.Json.setValue(this.data, "arrival", null);
this.assertEquals(this.thirdElement.value, "Set arrival", "The placeholder is not displayed after nullifying the datamodel to which the widget is bound");
this.assertTrue(this.cssClass3.contains("placeholder"), "Css class placeholder is not there");
+ aria.utils.Json.setValue(this.data, "arrival", "fake");
+ this.assertEquals(this.thirdElement.value, "fake", "The placeholder has not been removed");
+ this.assertFalse(this.cssClass3.contains("placeholder"), "Css class placeholder is not removed properly after bound data changes");
+
this.end();
}
Something went wrong with that request. Please try again.