Skip to content

Commit f54747b

Browse files
Adovenmuehlescottgonzalez
authored andcommitted
Accordion: Added .ui-accordion-heading class to header's first child. Fixes #6743 - Accordion: Add .ui-accordion-heading class.
1 parent 0cc1a0c commit f54747b

File tree

6 files changed

+25
-16
lines changed

6 files changed

+25
-16
lines changed

tests/unit/accordion/accordion.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ <h2 id="qunit-userAgent"></h2>
6464

6565
<div>
6666
<div id="list1" class="foo">
67-
<a class="bar">There is one obvious advantage:</a>
67+
<h3 class="bar"><a class="anchor">There is one obvious advantage:</a></h3>
6868
<div class="foo">
6969
<p>
7070
You've seen it coming!
@@ -74,7 +74,7 @@ <h2 id="qunit-userAgent"></h2>
7474
Well, at least no free beer. Perhaps a bear, if you can afford it.
7575
</p>
7676
</div>
77-
<a class="bar">Now that you've got...</a>
77+
<h3 class="bar"><a class="anchor">Now that you've got...</a></h3>
7878
<div class="foo">
7979
<p>
8080
your bear, you have to admit it!
@@ -85,7 +85,7 @@ <h2 id="qunit-userAgent"></h2>
8585
We could talk about renting one.
8686
</p>
8787
</div>
88-
<a class="bar">Rent one bear, ...</a>
88+
<h3 class="bar"><a class="anchor">Rent one bear, ...</a></h3>
8989
<div class="foo">
9090
<p>
9191
get two for three beer.

tests/unit/accordion/accordion_core.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ test("handle click on header-descendant", function() {
1313
state(ac, 0, 1, 0);
1414
});
1515

16+
test("ui-accordion-heading class added to headers anchor", function() {
17+
expect(1);
18+
var ac = $("#list1").accordion();
19+
var anchors = $(".ui-accordion-heading");
20+
equals( anchors.length, "3");
21+
});
22+
1623
test("accessibility", function () {
1724
expect(9);
1825
var ac = $('#list1').accordion().accordion("activate", 1);

tests/unit/accordion/accordion_methods.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ test("activate, boolean, collapsible: false", function() {
9595
});
9696

9797
test("activate, string expression", function() {
98-
var ac = $('#list1').accordion({ active: "a:last" });
98+
var ac = $('#list1').accordion({ active: "h3:last" });
9999
state(ac, 0, 0, 1);
100100
ac.accordion("activate", ":first");
101101
state(ac, 1, 0, 0);
@@ -106,11 +106,11 @@ test("activate, string expression", function() {
106106
});
107107

108108
test("activate, jQuery or DOM element", function() {
109-
var ac = $('#list1').accordion({ active: $("#list1 a:last") });
109+
var ac = $('#list1').accordion({ active: $("#list1 h3:last") });
110110
state(ac, 0, 0, 1);
111-
ac.accordion("activate", $("#list1 a:first"));
111+
ac.accordion("activate", $("#list1 h3:first"));
112112
state(ac, 1, 0, 0);
113-
ac.accordion("activate", $("#list1 a")[1]);
113+
ac.accordion("activate", $("#list1 h3")[1]);
114114
state(ac, 0, 1, 0);
115115
});
116116

tests/unit/accordion/accordion_options.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,28 @@ test("{ active: first child }, default", function() {
1313

1414
test("{ active: Selector }", function() {
1515
var ac = $("#list1").accordion({
16-
active: "a:last"
16+
active: "h3:last"
1717
});
1818
state(ac, 0, 0, 1);
19-
ac.accordion('option', 'active', "a:eq(1)");
19+
ac.accordion('option', 'active', "h3:eq(1)");
2020
state(ac, 0, 1, 0);
2121
});
2222

2323
test("{ active: Element }", function() {
2424
var ac = $("#list1").accordion({
25-
active: $("#list1 a:last")[0]
25+
active: $("#list1 h3:last")[0]
2626
});
2727
state(ac, 0, 0, 1);
28-
ac.accordion('option', 'active', $("#list1 a:eq(1)")[0]);
28+
ac.accordion('option', 'active', $("#list1 h3:eq(1)")[0]);
2929
state(ac, 0, 1, 0);
3030
});
3131

3232
test("{ active: jQuery Object }", function() {
3333
var ac = $("#list1").accordion({
34-
active: $("#list1 a:last")
34+
active: $("#list1 h3:last")
3535
});
3636
state(ac, 0, 0, 1);
37-
ac.accordion('option', 'active', $("#list1 a:eq(1)"));
37+
ac.accordion('option', 'active', $("#list1 h3:eq(1)"));
3838
state(ac, 0, 1, 0);
3939
});
4040

themes/base/jquery.ui.accordion.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
.ui-accordion .ui-accordion-header { cursor: pointer; position: relative; margin-top: 1px; zoom: 1; }
1313
.ui-accordion .ui-accordion-li-fix { display: inline; }
1414
.ui-accordion .ui-accordion-header-active { border-bottom: 0 !important; }
15-
.ui-accordion .ui-accordion-header a { display: block; font-size: 1em; padding: .5em .5em .5em .7em; }
16-
.ui-accordion-icons .ui-accordion-header a { padding-left: 2.2em; }
15+
.ui-accordion .ui-accordion-heading { display: block; font-size: 1em; padding: .5em .5em .5em .7em; }
16+
.ui-accordion-icons .ui-accordion-heading { padding-left: 2.2em; }
1717
.ui-accordion .ui-accordion-header .ui-icon { position: absolute; left: .5em; top: 50%; margin-top: -8px; }
1818
.ui-accordion .ui-accordion-content { padding: 1em 2.2em; border-top: 0; margin-top: -2px; position: relative; top: 1px; margin-bottom: 2px; overflow: auto; display: none; zoom: 1; }
19-
.ui-accordion .ui-accordion-content-active { display: block; }
19+
.ui-accordion .ui-accordion-content-active { display: block; }

ui/jquery.ui.accordion.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ $.widget( "ui.accordion", {
7575

7676
self.headers.next()
7777
.addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" );
78+
self.headers.find( ":first-child" ).addClass( "ui-accordion-heading" );
7879

7980
if ( options.navigation ) {
8081
var current = self.element.find( "a" ).filter( options.navigationFilter ).eq( 0 );
@@ -177,6 +178,7 @@ $.widget( "ui.accordion", {
177178

178179
this.headers.find( "a" ).removeAttr( "tabIndex" );
179180
this._destroyIcons();
181+
this.headers.find( "a:first-child" ).removeClass( "ui-accordion-heading" );
180182
var contents = this.headers.next()
181183
.css( "display", "" )
182184
.removeAttr( "role" )

0 commit comments

Comments
 (0)