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 // TODO(sjmiles): ensure read-only property is valued so the compound
53 if (this.focused === undefined) {
54 this._setFocused(false);
56 this.addEventListener('focus', this._boundFocusBlurHandler, true);
57 this.addEventListener('blur', this._boundFocusBlurHandler, true);
60 _focusBlurHandler: function(event) {
61 var target = event.path ? event.path[0] : event.target;
62 if (target === this) {
63 var focused = event.type === 'focus';
64 this._setFocused(focused);
65 } else if (!this.shadowRoot) {
66 event.stopPropagation();
67 this.fire(event.type, {sourceEvent: event}, {
69 bubbles: event.bubbles,
70 cancelable: event.cancelable
75 _disabledChanged: function(disabled, old) {
76 this.setAttribute('aria-disabled', disabled ? 'true' : 'false');
77 this.style.pointerEvents = disabled ? 'none' : '';
79 this._oldTabIndex = this.tabIndex;
82 } else if (this._oldTabIndex !== undefined) {
83 this.tabIndex = this._oldTabIndex;
87 _changedControlState: function() {
88 // _controlStateChanged is abstract, follow-on behaviors may implement it
89 if (this._controlStateChanged) {
90 this._controlStateChanged();