Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Unified Diff: third_party/polymer/v1_0/components-chromium/iron-behaviors/iron-button-state-extracted.js

Issue 1287713002: [MD settings] merge polymer 1.0.11; hack for settings checkbox (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/polymer/v1_0/components-chromium/iron-behaviors/iron-button-state-extracted.js
diff --git a/third_party/polymer/v1_0/components-chromium/iron-behaviors/iron-button-state-extracted.js b/third_party/polymer/v1_0/components-chromium/iron-behaviors/iron-button-state-extracted.js
index f9b7f99b5355b26d0e6606fe3b1dfe80c650061a..ae97f5cd1395f7a827ac5674ba7d2271d9cf1d12 100644
--- a/third_party/polymer/v1_0/components-chromium/iron-behaviors/iron-button-state-extracted.js
+++ b/third_party/polymer/v1_0/components-chromium/iron-behaviors/iron-button-state-extracted.js
@@ -1,6 +1,4 @@
-
-
- /**
+/**
* @demo demo/index.html
* @polymerBehavior Polymer.IronButtonState
*/
@@ -36,8 +34,7 @@
type: Boolean,
value: false,
notify: true,
- reflectToAttribute: true,
- observer: '_activeChanged'
+ reflectToAttribute: true
},
/**
@@ -58,6 +55,16 @@
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'
}
},
@@ -68,7 +75,8 @@
},
observers: [
- '_detectKeyboardFocus(focused)'
+ '_detectKeyboardFocus(focused)',
+ '_activeChanged(active, ariaActiveAttribute)'
],
keyBindings: {
@@ -95,8 +103,10 @@
// 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');
+ }
},
_eventSourceIsPrimaryInput: function(event) {
@@ -164,11 +174,18 @@
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();
},
@@ -195,5 +212,4 @@
Polymer.IronButtonState = [
Polymer.IronA11yKeysBehavior,
Polymer.IronButtonStateImpl
- ];
-
+ ];

Powered by Google App Engine
This is Rietveld 408576698