OLD | NEW |
1 | 1 Polymer({ |
2 Polymer({ | |
3 is: 'paper-radio-button', | 2 is: 'paper-radio-button', |
4 | 3 |
5 behaviors: [ | 4 behaviors: [ |
6 Polymer.PaperInkyFocusBehavior | 5 Polymer.PaperInkyFocusBehavior |
7 ], | 6 ], |
8 | 7 |
9 hostAttributes: { | 8 hostAttributes: { |
10 role: 'radio', | 9 role: 'radio', |
11 'aria-checked': false, | 10 'aria-checked': false, |
12 tabindex: 0 | 11 tabindex: 0 |
(...skipping 27 matching lines...) Expand all Loading... |
40 * If true, the button toggles the active state with each tap or press | 39 * If true, the button toggles the active state with each tap or press |
41 * of the spacebar. | 40 * of the spacebar. |
42 */ | 41 */ |
43 toggles: { | 42 toggles: { |
44 type: Boolean, | 43 type: Boolean, |
45 value: true, | 44 value: true, |
46 reflectToAttribute: true | 45 reflectToAttribute: true |
47 } | 46 } |
48 }, | 47 }, |
49 | 48 |
50 ready: function() { | 49 attached: function() { |
51 if (Polymer.dom(this).textContent == '') { | 50 var trimmedText = Polymer.dom(this).textContent.trim(); |
| 51 if (trimmedText === '') { |
52 this.$.radioLabel.hidden = true; | 52 this.$.radioLabel.hidden = true; |
53 } else { | 53 } |
54 this.setAttribute('aria-label', Polymer.dom(this).textContent); | 54 // Don't stomp over a user-set aria-label. |
| 55 if (trimmedText !== '' && !this.getAttribute('aria-label')) { |
| 56 this.setAttribute('aria-label', trimmedText); |
55 } | 57 } |
56 this._isReady = true; | 58 this._isReady = true; |
57 }, | 59 }, |
58 | 60 |
59 _buttonStateChanged: function() { | 61 _buttonStateChanged: function() { |
60 if (this.disabled) { | 62 if (this.disabled) { |
61 return; | 63 return; |
62 } | 64 } |
63 if (this._isReady) { | 65 if (this._isReady) { |
64 this.checked = this.active; | 66 this.checked = this.active; |
65 } | 67 } |
66 }, | 68 }, |
67 | 69 |
68 _checkedChanged: function() { | 70 _checkedChanged: function() { |
69 this.setAttribute('aria-checked', this.checked ? 'true' : 'false'); | 71 this.setAttribute('aria-checked', this.checked ? 'true' : 'false'); |
70 this.active = this.checked; | 72 this.active = this.checked; |
71 this.fire('iron-change'); | 73 this.fire('iron-change'); |
72 } | 74 } |
73 }) | 75 }); |
74 ; | |
OLD | NEW |