4 * @demo demo/index.html
7 Polymer.IronControlState = {
12 * If true, the element currently has focus.
19 reflectToAttribute: true
23 * If true, the user cannot interact with this element.
29 observer: '_disabledChanged',
30 reflectToAttribute: true
37 _boundFocusBlurHandler: {
40 return this._focusBlurHandler.bind(this);
47 '_changedControlState(focused, disabled)'
51 this.addEventListener('focus', this._boundFocusBlurHandler, true);
52 this.addEventListener('blur', this._boundFocusBlurHandler, true);
55 _focusBlurHandler: function(event) {
56 // NOTE(cdata): if we are in ShadowDOM land, `event.target` will
57 // eventually become `this` due to retargeting; if we are not in
58 // ShadowDOM land, `event.target` will eventually become `this` due
59 // to the second conditional which fires a synthetic event (that is also
60 // handled). In either case, we can disregard `event.path`.
62 if (event.target === this) {
63 var focused = event.type === 'focus';
64 this._setFocused(focused);
65 } else if (!this.shadowRoot) {
66 this.fire(event.type, {sourceEvent: event}, {
68 bubbles: event.bubbles,
69 cancelable: event.cancelable
74 _disabledChanged: function(disabled, old) {
75 this.setAttribute('aria-disabled', disabled ? 'true' : 'false');
76 this.style.pointerEvents = disabled ? 'none' : '';
78 this._oldTabIndex = this.tabIndex;
81 } else if (this._oldTabIndex !== undefined) {
82 this.tabIndex = this._oldTabIndex;
86 _changedControlState: function() {
87 // _controlStateChanged is abstract, follow-on behaviors may implement it
88 if (this._controlStateChanged) {
89 this._controlStateChanged();