Index: third_party/polymer/v1_0/components/iron-autogrow-textarea/iron-autogrow-textarea.html |
diff --git a/third_party/polymer/v1_0/components/iron-autogrow-textarea/iron-autogrow-textarea.html b/third_party/polymer/v1_0/components/iron-autogrow-textarea/iron-autogrow-textarea.html |
index 376177d8483d16830f0ad47361f6800df614cfdd..cb1cd3391aeed06d817287af6fb8aab9a37ecca4 100644 |
--- a/third_party/polymer/v1_0/components/iron-autogrow-textarea/iron-autogrow-textarea.html |
+++ b/third_party/polymer/v1_0/components/iron-autogrow-textarea/iron-autogrow-textarea.html |
@@ -9,8 +9,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN |
--> |
<link rel="import" href="../polymer/polymer.html"> |
+<link rel="import" href="../iron-behaviors/iron-control-state.html"> |
<link rel="import" href="../iron-flex-layout/classes/iron-flex-layout.html"> |
<link rel="import" href="../iron-validatable-behavior/iron-validatable-behavior.html"> |
+<link rel="import" href="../iron-form-element-behavior/iron-form-element-behavior.html"> |
<!-- |
`iron-autogrow-textarea` is an element containing a textarea that grows in height as more |
@@ -55,6 +57,7 @@ this element's `bind-value` instead for imperative updates. |
border: none; |
resize: none; |
background: inherit; |
+ color: inherit; |
/* see comments in template */ |
width: 100%; |
height: 100%; |
@@ -77,7 +80,6 @@ this element's `bind-value` instead for imperative updates. |
autocomplete$="[[autocomplete]]" |
autofocus$="[[autofocus]]" |
inputmode$="[[inputmode]]" |
- name$="[[name]]" |
placeholder$="[[placeholder]]" |
readonly$="[[readonly]]" |
required$="[[required]]" |
@@ -85,6 +87,7 @@ this element's `bind-value` instead for imperative updates. |
maxlength$="[[maxlength]]"></textarea> |
</div> |
</template> |
+</dom-module> |
<script> |
@@ -93,7 +96,9 @@ this element's `bind-value` instead for imperative updates. |
is: 'iron-autogrow-textarea', |
behaviors: [ |
- Polymer.IronValidatableBehavior |
+ Polymer.IronFormElementBehavior, |
+ Polymer.IronValidatableBehavior, |
+ Polymer.IronControlState |
], |
properties: { |
@@ -164,6 +169,15 @@ this element's `bind-value` instead for imperative updates. |
}, |
/** |
+ * The value for this input, same as `bindValue` |
+ */ |
+ value: { |
+ notify: true, |
+ type: String, |
+ computed: '_computeValue(bindValue)' |
+ }, |
+ |
+ /** |
* Bound to the textarea's `placeholder` attribute. |
*/ |
placeholder: { |
@@ -199,11 +213,36 @@ this element's `bind-value` instead for imperative updates. |
/** |
* Returns the underlying textarea. |
+ * @type HTMLTextAreaElement |
*/ |
get textarea() { |
return this.$.textarea; |
}, |
+ /** |
+ * Returns true if `value` is valid. The validator provided in `validator` |
+ * will be used first, if it exists; otherwise, the `textarea`'s validity |
+ * is used. |
+ * @return {boolean} True if the value is valid. |
+ */ |
+ validate: function() { |
+ // Empty, non-required input is valid. |
+ if (!this.required && this.value == '') { |
+ this.invalid = false; |
+ return true; |
+ } |
+ |
+ var valid; |
+ if (this.hasValidator()) { |
+ valid = Polymer.IronValidatableBehavior.validate.call(this, this.value); |
+ } else { |
+ valid = this.$.textarea.validity.valid; |
+ this.invalid = !valid; |
+ } |
+ this.fire('iron-input-validate'); |
+ return valid; |
+ }, |
+ |
_update: function() { |
this.$.mirror.innerHTML = this._valueForMirror(); |
@@ -258,6 +297,10 @@ this element's `bind-value` instead for imperative updates. |
_updateCached: function() { |
this.$.mirror.innerHTML = this._constrain(this.tokens); |
+ }, |
+ |
+ _computeValue: function() { |
+ return this.bindValue; |
} |
}) |
</script> |