| Index: third_party/polymer/v1_0/components/paper-input/paper-input-behavior.html
|
| diff --git a/third_party/polymer/v1_0/components/paper-input/paper-input-behavior.html b/third_party/polymer/v1_0/components/paper-input/paper-input-behavior.html
|
| index 06a4e545c5e5dada539da2342944a0551c52acb8..1e72e983eb2772356768528121a84b556ca5cadf 100644
|
| --- a/third_party/polymer/v1_0/components/paper-input/paper-input-behavior.html
|
| +++ b/third_party/polymer/v1_0/components/paper-input/paper-input-behavior.html
|
| @@ -201,7 +201,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
| * A placeholder string in addition to the label. If this is set, the label will always float.
|
| */
|
| placeholder: {
|
| - type: String
|
| + type: String,
|
| + // need to set a default so _computeAlwaysFloatLabel is run
|
| + value: ''
|
| },
|
|
|
| /**
|
| @@ -264,10 +266,32 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
| /**
|
| * Validates the input element and sets an error style if needed.
|
| */
|
| - validate: function () {
|
| + validate: function() {
|
| return this.inputElement.validate();
|
| },
|
|
|
| + /**
|
| + * Restores the cursor to its original position after updating the value.
|
| + * @param {string} newValue The value that should be saved.
|
| + */
|
| + updateValueAndPreserveCaret: function(newValue) {
|
| + // Not all elements might have selection, and even if they have the
|
| + // right properties, accessing them might throw an exception (like for
|
| + // <input type=number>)
|
| + try {
|
| + var start = this.inputElement.selectionStart;
|
| + this.value = newValue;
|
| +
|
| + // The cursor automatically jumps to the end after re-setting the value,
|
| + // so restore it to its original position.
|
| + this.inputElement.selectionStart = start;
|
| + this.inputElement.selectionEnd = start;
|
| + } catch (e) {
|
| + // Just set the value and give up on the caret.
|
| + this.value = newValue;
|
| + }
|
| + },
|
| +
|
| _computeAlwaysFloatLabel: function(alwaysFloatLabel, placeholder) {
|
| return placeholder || alwaysFloatLabel;
|
| },
|
|
|