Index: polymer_1.2.3/iron-behaviors/iron-button-state.html |
diff --git a/polymer_1.0.4/bower_components/iron-behaviors/iron-button-state.html b/polymer_1.2.3/iron-behaviors/iron-button-state.html |
similarity index 72% |
copy from polymer_1.0.4/bower_components/iron-behaviors/iron-button-state.html |
copy to polymer_1.2.3/iron-behaviors/iron-button-state.html |
index fc52e172f920d899737e5800564b8730cff3764e..8114e2ddea8de7bfbe069304e56e7aef6640d425 100644 |
--- a/polymer_1.0.4/bower_components/iron-behaviors/iron-button-state.html |
+++ b/polymer_1.2.3/iron-behaviors/iron-button-state.html |
@@ -50,8 +50,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN |
type: Boolean, |
value: false, |
notify: true, |
- reflectToAttribute: true, |
- observer: '_activeChanged' |
+ reflectToAttribute: true |
}, |
/** |
@@ -72,6 +71,16 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN |
receivedFocusFromKeyboard: { |
type: Boolean, |
readOnly: true |
+ }, |
+ |
+ /** |
+ * The aria attribute to be set if the button is a toggle and in the |
+ * active state. |
+ */ |
+ ariaActiveAttribute: { |
+ type: String, |
+ value: 'aria-pressed', |
+ observer: '_ariaActiveAttributeChanged' |
} |
}, |
@@ -82,7 +91,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN |
}, |
observers: [ |
- '_detectKeyboardFocus(focused)' |
+ '_detectKeyboardFocus(focused)', |
+ '_activeChanged(active, ariaActiveAttribute)' |
], |
keyBindings: { |
@@ -91,6 +101,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN |
'space:keyup': '_spaceKeyUpHandler', |
}, |
+ _mouseEventRe: /^mouse/, |
+ |
_tapHandler: function() { |
if (this.toggles) { |
// a tap is needed to toggle the active state |
@@ -107,11 +119,13 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN |
// to emulate native checkbox, (de-)activations from a user interaction fire |
// 'change' events |
_userActivate: function(active) { |
- this.active = active; |
- this.fire('change'); |
+ if (this.active !== active) { |
+ this.active = active; |
+ this.fire('change'); |
+ } |
}, |
- _downHandler: function() { |
+ _downHandler: function(event) { |
this._setPointerDown(true); |
this._setPressed(true); |
this._setReceivedFocusFromKeyboard(false); |
@@ -122,14 +136,35 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN |
this._setPressed(false); |
}, |
+ /** |
+ * @param {!KeyboardEvent} event . |
+ */ |
_spaceKeyDownHandler: function(event) { |
var keyboardEvent = event.detail.keyboardEvent; |
+ var target = Polymer.dom(keyboardEvent).localTarget; |
+ |
+ // Ignore the event if this is coming from a focused light child, since that |
+ // element will deal with it. |
+ if (this.isLightDescendant(/** @type {Node} */(target))) |
+ return; |
+ |
keyboardEvent.preventDefault(); |
keyboardEvent.stopImmediatePropagation(); |
this._setPressed(true); |
}, |
- _spaceKeyUpHandler: function() { |
+ /** |
+ * @param {!KeyboardEvent} event . |
+ */ |
+ _spaceKeyUpHandler: function(event) { |
+ var keyboardEvent = event.detail.keyboardEvent; |
+ var target = Polymer.dom(keyboardEvent).localTarget; |
+ |
+ // Ignore the event if this is coming from a focused light child, since that |
+ // element will deal with it. |
+ if (this.isLightDescendant(/** @type {Node} */(target))) |
+ return; |
+ |
if (this.pressed) { |
this._asyncClick(); |
} |
@@ -150,11 +185,18 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN |
this._changedButtonState(); |
}, |
- _activeChanged: function(active) { |
+ _ariaActiveAttributeChanged: function(value, oldValue) { |
+ if (oldValue && oldValue != value && this.hasAttribute(oldValue)) { |
+ this.removeAttribute(oldValue); |
+ } |
+ }, |
+ |
+ _activeChanged: function(active, ariaActiveAttribute) { |
if (this.toggles) { |
- this.setAttribute('aria-pressed', active ? 'true' : 'false'); |
+ this.setAttribute(this.ariaActiveAttribute, |
+ active ? 'true' : 'false'); |
} else { |
- this.removeAttribute('aria-pressed'); |
+ this.removeAttribute(this.ariaActiveAttribute); |
} |
this._changedButtonState(); |
}, |