| OLD | NEW |
| 1 (function() { | 1 Polymer({ |
| 2 | |
| 3 Polymer({ | |
| 4 | |
| 5 is: 'paper-input-char-counter', | 2 is: 'paper-input-char-counter', |
| 6 | 3 |
| 7 behaviors: [ | 4 behaviors: [ |
| 8 Polymer.PaperInputAddonBehavior | 5 Polymer.PaperInputAddonBehavior |
| 9 ], | 6 ], |
| 10 | 7 |
| 11 properties: { | 8 properties: { |
| 12 | |
| 13 _charCounterStr: { | 9 _charCounterStr: { |
| 14 type: String, | 10 type: String, |
| 15 value: '0' | 11 value: '0' |
| 16 } | 12 } |
| 17 | |
| 18 }, | 13 }, |
| 19 | 14 |
| 20 update: function(state) { | 15 update: function(state) { |
| 21 if (!state.inputElement) { | 16 if (!state.inputElement) { |
| 22 return; | 17 return; |
| 23 } | 18 } |
| 24 | 19 |
| 25 state.value = state.value || ''; | 20 state.value = state.value || ''; |
| 26 | 21 |
| 27 // Account for the textarea's new lines. | 22 // Account for the textarea's new lines. |
| 28 var str = state.value.replace(/(\r\n|\n|\r)/g, '--').length; | 23 var str = state.value.replace(/(\r\n|\n|\r)/g, '--').length; |
| 29 | 24 |
| 30 if (state.inputElement.hasAttribute('maxlength')) { | 25 if (state.inputElement.hasAttribute('maxlength')) { |
| 31 str += '/' + state.inputElement.getAttribute('maxlength'); | 26 str += '/' + state.inputElement.getAttribute('maxlength'); |
| 32 } | 27 } |
| 33 this._charCounterStr = str; | 28 this._charCounterStr = str; |
| 34 } | 29 } |
| 35 | 30 }); |
| 36 }); | |
| 37 | |
| 38 })(); | |
| OLD | NEW |