From 3fe4fa8424355d5a74ef5fc6f122670263aa0d5f Mon Sep 17 00:00:00 2001 From: Anna Pankova Date: Sat, 22 Apr 2017 21:19:25 +0300 Subject: [PATCH 1/3] Fixed #21237 - Toggle buttons don't honor [disabled] or .disabled --- js/src/button.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/js/src/button.js b/js/src/button.js index 6295d0db055b..79a870bef815 100644 --- a/js/src/button.js +++ b/js/src/button.js @@ -90,6 +90,11 @@ const Button = (($) => { } if (triggerChangeEvent) { + if (input.disabled || rootElement.disabled || + input.classList.contains('disabled') || + rootElement.classList.contains('disabled')) { + return + } input.checked = !$(this._element).hasClass(ClassName.ACTIVE) $(input).trigger('change') } From fd10cad4c56a5125ac7687b4e4d6ba33429f8140 Mon Sep 17 00:00:00 2001 From: Anna Pankova Date: Mon, 24 Apr 2017 20:34:44 +0300 Subject: [PATCH 2/3] #22499 - use `hasAttribute` for disabled button checks --- js/src/button.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/src/button.js b/js/src/button.js index 79a870bef815..722fd489de61 100644 --- a/js/src/button.js +++ b/js/src/button.js @@ -90,7 +90,8 @@ const Button = (($) => { } if (triggerChangeEvent) { - if (input.disabled || rootElement.disabled || + if (input.hasAttribute('disabled') || + rootElement.hasAttribute('disabled') || input.classList.contains('disabled') || rootElement.classList.contains('disabled')) { return From 4e477eedaed8813a8b8ca4ee709f961a1dd8089b Mon Sep 17 00:00:00 2001 From: Anna Pankova Date: Tue, 25 Apr 2017 12:43:11 +0300 Subject: [PATCH 3/3] #22499 - tests added --- js/tests/unit/button.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/js/tests/unit/button.js b/js/tests/unit/button.js index abc04e10a90e..489d400a6ce7 100644 --- a/js/tests/unit/button.js +++ b/js/tests/unit/button.js @@ -156,4 +156,21 @@ $(function () { assert.ok($btn2.is(':not([aria-pressed])'), 'label for nested radio input has not been given an aria-pressed attribute') }) + QUnit.test('should handle disabled attribute on non-button elements', function (assert) { + assert.expect(2) + var groupHTML = '
' + + '' + + '
' + var $group = $(groupHTML).appendTo('#qunit-fixture') + + var $btn = $group.children().eq(0) + var $input = $btn.children().eq(0) + + $btn.trigger('click') + assert.ok($btn.is(':not(.active)'), 'button did not become active') + assert.ok(!$input.is(':checked'), 'checkbox did not get checked') + }) + })