From c60dc038a402abf297fd83d5016554b2840d8fd1 Mon Sep 17 00:00:00 2001 From: August Toman-Yih Date: Mon, 3 Aug 2015 11:53:00 -0700 Subject: [PATCH] [fixed] only add aria-expanded to Collapse when an ARIA role is present Also remove redundant aria-expanded from Panel collapsible body Signed-off-by: Kenny Wang --- src/Collapse.js | 9 +++++++-- src/Panel.js | 3 +-- test/CollapseSpec.js | 20 ++++++++++++++++++++ test/PanelSpec.js | 4 ---- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/Collapse.js b/src/Collapse.js index 2a632f55e9..ab8e4b652f 100644 --- a/src/Collapse.js +++ b/src/Collapse.js @@ -48,7 +48,7 @@ class Collapse extends React.Component { + ref='panel'> {this.renderBody()} diff --git a/test/CollapseSpec.js b/test/CollapseSpec.js index 0ac893fcf0..8b7f71509c 100644 --- a/test/CollapseSpec.js +++ b/test/CollapseSpec.js @@ -213,4 +213,24 @@ describe('Collapse', function () { assert.equal(instance.collapse._dimension(), 'whatevs'); }); }); + + describe('with a role', function() { + beforeEach(function(){ + instance = ReactTestUtils.renderIntoDocument( + Panel content + ); + }); + + it('sets aria-expanded true when expanded', function() { + let node = React.findDOMNode(instance); + instance.setProps({ in: true}); + assert.equal(node.getAttribute('aria-expanded'), 'true'); + }); + + it('sets aria-expanded false when collapsed', function() { + let node = React.findDOMNode(instance); + instance.setProps({ in: false}); + assert.equal(node.getAttribute('aria-expanded'), 'false'); + }); + }); }); diff --git a/test/PanelSpec.js b/test/PanelSpec.js index aba23266d0..0c9cfc09f1 100644 --- a/test/PanelSpec.js +++ b/test/PanelSpec.js @@ -191,9 +191,7 @@ describe('Panel', function () { let instance = ReactTestUtils.renderIntoDocument( Panel content ); - let collapse = React.findDOMNode(instance).querySelector('.panel-collapse'); let anchor = React.findDOMNode(instance).querySelector('.panel-title a'); - assert.equal(collapse.getAttribute('aria-expanded'), 'true'); assert.equal(anchor.getAttribute('aria-expanded'), 'true'); }); @@ -201,9 +199,7 @@ describe('Panel', function () { let instance = ReactTestUtils.renderIntoDocument( Panel content ); - let collapse = React.findDOMNode(instance).querySelector('.panel-collapse'); let anchor = React.findDOMNode(instance).querySelector('.panel-title a'); - assert.equal(collapse.getAttribute('aria-expanded'), 'false'); assert.equal(anchor.getAttribute('aria-expanded'), 'false'); });