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