From 8bc5da57b09d77663c7b6ef81dafeec4b9873f95 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Wed, 28 Mar 2018 09:11:50 +0800 Subject: [PATCH] No need to default `aria-label` to label. --- .../javascripts/discourse/components/d-button.js.es6 | 7 +------ .../javascripts/discourse/widgets/button.js.es6 | 12 ++++-------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/app/assets/javascripts/discourse/components/d-button.js.es6 b/app/assets/javascripts/discourse/components/d-button.js.es6 index 13e36edc717..464a434bf11 100644 --- a/app/assets/javascripts/discourse/components/d-button.js.es6 +++ b/app/assets/javascripts/discourse/components/d-button.js.es6 @@ -6,7 +6,7 @@ export default Ember.Component.extend({ tagName: 'button', classNameBindings: [':btn', 'noText', 'btnType'], - attributeBindings: ['disabled', 'translatedTitle:title', 'ariaLabel:aria-label', 'tabindex'], + attributeBindings: ['disabled', 'translatedTitle:title', 'translatedTitle:aria-label', 'tabindex'], btnIcon: Ember.computed.notEmpty('icon'), @@ -31,11 +31,6 @@ export default Ember.Component.extend({ if (label) return I18n.t(label); }, - @computed("translatedTitle", "translatedLabel") - ariaLabel(translatedTitle, translatedLabel) { - return translatedTitle ? translatedTitle : translatedLabel; - }, - click() { this.sendAction("action", this.get("actionParam")); return false; diff --git a/app/assets/javascripts/discourse/widgets/button.js.es6 b/app/assets/javascripts/discourse/widgets/button.js.es6 index b9b288676a2..1794c0ab857 100644 --- a/app/assets/javascripts/discourse/widgets/button.js.es6 +++ b/app/assets/javascripts/discourse/widgets/button.js.es6 @@ -28,18 +28,14 @@ export const ButtonClass = { buildAttributes() { const attrs = this.attrs; + const attributes = {}; - let title; if (attrs.title) { - title = I18n.t(attrs.title, attrs.titleOptions); + const title = I18n.t(attrs.title, attrs.titleOptions); + attributes["aria-label"] = title; + attributes.title = title; } - let label; - if (attrs.label) { - label = I18n.t(attrs.label, attrs.labelOptions); - } - - const attributes = { "aria-label": label, title }; if (attrs.disabled) { attributes.disabled = "true"; } if (attrs.data) {