| OLD | NEW |
| 1 /** | 1 /** |
| 2 * @demo demo/index.html | 2 * @demo demo/index.html |
| 3 * @polymerBehavior | 3 * @polymerBehavior |
| 4 */ | 4 */ |
| 5 Polymer.IronControlState = { | 5 Polymer.IronControlState = { |
| 6 | 6 |
| 7 properties: { | 7 properties: { |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * If true, the element currently has focus. | 10 * If true, the element currently has focus. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 observers: [ | 44 observers: [ |
| 45 '_changedControlState(focused, disabled)' | 45 '_changedControlState(focused, disabled)' |
| 46 ], | 46 ], |
| 47 | 47 |
| 48 ready: function() { | 48 ready: function() { |
| 49 this.addEventListener('focus', this._boundFocusBlurHandler, true); | 49 this.addEventListener('focus', this._boundFocusBlurHandler, true); |
| 50 this.addEventListener('blur', this._boundFocusBlurHandler, true); | 50 this.addEventListener('blur', this._boundFocusBlurHandler, true); |
| 51 }, | 51 }, |
| 52 | 52 |
| 53 _focusBlurHandler: function(event) { | 53 _focusBlurHandler: function(event) { |
| 54 var target = event.path ? event.path[0] : event.target; | 54 // NOTE(cdata): if we are in ShadowDOM land, `event.target` will |
| 55 if (target === this) { | 55 // eventually become `this` due to retargeting; if we are not in |
| 56 // ShadowDOM land, `event.target` will eventually become `this` due |
| 57 // to the second conditional which fires a synthetic event (that is also |
| 58 // handled). In either case, we can disregard `event.path`. |
| 59 |
| 60 if (event.target === this) { |
| 56 var focused = event.type === 'focus'; | 61 var focused = event.type === 'focus'; |
| 57 this._setFocused(focused); | 62 this._setFocused(focused); |
| 58 } else if (!this.shadowRoot) { | 63 } else if (!this.shadowRoot) { |
| 59 this.fire(event.type, {sourceEvent: event}, { | 64 this.fire(event.type, {sourceEvent: event}, { |
| 60 node: this, | 65 node: this, |
| 61 bubbles: event.bubbles, | 66 bubbles: event.bubbles, |
| 62 cancelable: event.cancelable | 67 cancelable: event.cancelable |
| 63 }); | 68 }); |
| 64 } | 69 } |
| 65 }, | 70 }, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 77 }, | 82 }, |
| 78 | 83 |
| 79 _changedControlState: function() { | 84 _changedControlState: function() { |
| 80 // _controlStateChanged is abstract, follow-on behaviors may implement it | 85 // _controlStateChanged is abstract, follow-on behaviors may implement it |
| 81 if (this._controlStateChanged) { | 86 if (this._controlStateChanged) { |
| 82 this._controlStateChanged(); | 87 this._controlStateChanged(); |
| 83 } | 88 } |
| 84 } | 89 } |
| 85 | 90 |
| 86 }; | 91 }; |
| OLD | NEW |