Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1494)

Unified Diff: third_party/polymer/v1_0/components-chromium/paper-input/paper-input-behavior-extracted.js

Issue 1187823002: Update Polymer components and re-run reproduce.sh (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/polymer/v1_0/components-chromium/paper-input/paper-input-behavior-extracted.js
diff --git a/third_party/polymer/v1_0/components-chromium/paper-input/paper-input-behavior-extracted.js b/third_party/polymer/v1_0/components-chromium/paper-input/paper-input-behavior-extracted.js
index 2a0d54c4b5aec7eec1da66aeb551c8131412d8d0..ff51360788b29438ffbe1d82570acb845d4747a6 100644
--- a/third_party/polymer/v1_0/components-chromium/paper-input/paper-input-behavior-extracted.js
+++ b/third_party/polymer/v1_0/components-chromium/paper-input/paper-input-behavior-extracted.js
@@ -190,7 +190,9 @@
* 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: ''
},
/**
@@ -253,10 +255,32 @@
/**
* 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;
},

Powered by Google App Engine
This is Rietveld 408576698