| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 @license | 2 @license |
| 3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. | 3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
| 4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | 4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
| 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
| 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
| 7 Code distributed by Google as part of the polymer project is also | 7 Code distributed by Google as part of the polymer project is also |
| 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt | 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
| 9 --> | 9 --> |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 } | 53 } |
| 54 } | 54 } |
| 55 | 55 |
| 56 }, | 56 }, |
| 57 | 57 |
| 58 observers: [ | 58 observers: [ |
| 59 '_changedControlState(focused, disabled)' | 59 '_changedControlState(focused, disabled)' |
| 60 ], | 60 ], |
| 61 | 61 |
| 62 ready: function() { | 62 ready: function() { |
| 63 // TODO(sjmiles): ensure read-only property is valued so the compound | |
| 64 // observer will fire | |
| 65 if (this.focused === undefined) { | |
| 66 this._setFocused(false); | |
| 67 } | |
| 68 this.addEventListener('focus', this._boundFocusBlurHandler, true); | 63 this.addEventListener('focus', this._boundFocusBlurHandler, true); |
| 69 this.addEventListener('blur', this._boundFocusBlurHandler, true); | 64 this.addEventListener('blur', this._boundFocusBlurHandler, true); |
| 70 }, | 65 }, |
| 71 | 66 |
| 72 _focusBlurHandler: function(event) { | 67 _focusBlurHandler: function(event) { |
| 73 var target = event.path ? event.path[0] : event.target; | 68 // NOTE(cdata): if we are in ShadowDOM land, `event.target` will |
| 74 if (target === this) { | 69 // eventually become `this` due to retargeting; if we are not in |
| 75 var focused = event.type === 'focus'; | 70 // ShadowDOM land, `event.target` will eventually become `this` due |
| 76 this._setFocused(focused); | 71 // to the second conditional which fires a synthetic event (that is also |
| 77 } else if (!this.shadowRoot) { | 72 // handled). In either case, we can disregard `event.path`. |
| 78 event.stopPropagation(); | 73 |
| 74 if (event.target === this) { |
| 75 this._setFocused(event.type === 'focus'); |
| 76 } else if (!this.shadowRoot && !this.isLightDescendant(event.target)) { |
| 79 this.fire(event.type, {sourceEvent: event}, { | 77 this.fire(event.type, {sourceEvent: event}, { |
| 80 node: this, | 78 node: this, |
| 81 bubbles: event.bubbles, | 79 bubbles: event.bubbles, |
| 82 cancelable: event.cancelable | 80 cancelable: event.cancelable |
| 83 }); | 81 }); |
| 84 } | 82 } |
| 85 }, | 83 }, |
| 86 | 84 |
| 87 _disabledChanged: function(disabled, old) { | 85 _disabledChanged: function(disabled, old) { |
| 88 this.setAttribute('aria-disabled', disabled ? 'true' : 'false'); | 86 this.setAttribute('aria-disabled', disabled ? 'true' : 'false'); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 99 _changedControlState: function() { | 97 _changedControlState: function() { |
| 100 // _controlStateChanged is abstract, follow-on behaviors may implement it | 98 // _controlStateChanged is abstract, follow-on behaviors may implement it |
| 101 if (this._controlStateChanged) { | 99 if (this._controlStateChanged) { |
| 102 this._controlStateChanged(); | 100 this._controlStateChanged(); |
| 103 } | 101 } |
| 104 } | 102 } |
| 105 | 103 |
| 106 }; | 104 }; |
| 107 | 105 |
| 108 </script> | 106 </script> |
| OLD | NEW |