| OLD | NEW |
| 1 Polymer({ | 1 Polymer({ |
| 2 is: 'paper-tab', | 2 is: 'paper-tab', |
| 3 | 3 |
| 4 behaviors: [ | 4 behaviors: [ |
| 5 Polymer.IronControlState, | 5 Polymer.IronControlState, |
| 6 Polymer.IronButtonState, | 6 Polymer.IronButtonState, |
| 7 Polymer.PaperRippleBehavior | 7 Polymer.PaperRippleBehavior |
| 8 ], | 8 ], |
| 9 | 9 |
| 10 properties: { |
| 11 |
| 12 /** |
| 13 * If true, the tab will forward keyboard clicks (enter/space) to |
| 14 * the first anchor element found in its descendants |
| 15 */ |
| 16 link: { |
| 17 type: Boolean, |
| 18 value: false, |
| 19 reflectToAttribute: true |
| 20 } |
| 21 |
| 22 }, |
| 23 |
| 10 hostAttributes: { | 24 hostAttributes: { |
| 11 role: 'tab' | 25 role: 'tab' |
| 12 }, | 26 }, |
| 13 | 27 |
| 14 listeners: { | 28 listeners: { |
| 15 down: '_updateNoink' | 29 down: '_updateNoink', |
| 30 tap: '_onTap' |
| 16 }, | 31 }, |
| 17 | 32 |
| 18 attached: function() { | 33 attached: function() { |
| 19 this._updateNoink(); | 34 this._updateNoink(); |
| 20 }, | 35 }, |
| 21 | 36 |
| 22 get _parentNoink () { | 37 get _parentNoink () { |
| 23 var parent = Polymer.dom(this).parentNode; | 38 var parent = Polymer.dom(this).parentNode; |
| 24 return !!parent && !!parent.noink; | 39 return !!parent && !!parent.noink; |
| 25 }, | 40 }, |
| 26 | 41 |
| 27 _updateNoink: function() { | 42 _updateNoink: function() { |
| 28 this.noink = !!this.noink || !!this._parentNoink; | 43 this.noink = !!this.noink || !!this._parentNoink; |
| 44 }, |
| 45 |
| 46 _onTap: function(event) { |
| 47 if (this.link) { |
| 48 var anchor = this.queryEffectiveChildren('a'); |
| 49 |
| 50 if (!anchor) { |
| 51 return; |
| 52 } |
| 53 |
| 54 // Don't get stuck in a loop delegating |
| 55 // the listener from the child anchor |
| 56 if (event.target === anchor) { |
| 57 return; |
| 58 } |
| 59 |
| 60 anchor.click(); |
| 61 } |
| 29 } | 62 } |
| 63 |
| 30 }); | 64 }); |
| OLD | NEW |