Skip to content

Commit 417d5b2

Browse files
committed
accordion: Fix for #4695
1 parent e132c1b commit 417d5b2

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

tests/unit/accordion/accordion.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
</div>
5757
</div>
5858

59+
<div id="navigationWrapper">
5960
<ul id="navigation">
6061
<li>
6162
<h2><a href="?p=1.1.1">Guitar</a></h2>
@@ -88,6 +89,7 @@ <h2><a href="?p=1.1.3">Drums</a></h2>
8889
</ul>
8990
</li>
9091
</ul>
92+
</div>
9193

9294
</div>
9395

tests/unit/accordion/accordion_options.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,19 @@ test("{ event: 'mouseover' }", function() {
112112
});
113113

114114
test("{ fillSpace: false }, default", function() {
115-
ok(false, 'missing test - untested code is broken code');
115+
$("#navigationWrapper").height(500);
116+
$('#navigation').accordion({ fillSpace: false });
117+
equals( $('#navigation > li:eq(0) > ul').height(), 126 );
118+
equals( $('#navigation > li:eq(1) > ul').height(), 126 );
119+
equals( $('#navigation > li:eq(2) > ul').height(), 126 );
116120
});
117121

118122
test("{ fillSpace: true }", function() {
119-
ok(false, 'missing test - untested code is broken code');
123+
$("#navigationWrapper").height(500);
124+
$('#navigation').accordion({ fillSpace: true });
125+
equals( $('#navigation > li:eq(0) > ul').height(), 386 );
126+
equals( $('#navigation > li:eq(1) > ul').height(), 386 );
127+
equals( $('#navigation > li:eq(2) > ul').height(), 386 );
120128
});
121129

122130
test("{ header: '> li > :first-child,> :not(li):even' }, default", function() {

tests/visual/accordion/accordion_option_fillSpace_true.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
<div style="height: 500px; width: 500px; border: 1px solid red;">
2121
<div id="accordion" style="width:490px;">
2222
<h3><a href="#">Accordion Header 1</a></h3>
23-
<div>
23+
<div style="padding-top: 1em">
2424
Accordion Content 1
2525
</div>
2626
<h3><a href="#">Accordion Header 2</a></h3>
27-
<div>
27+
<div style="padding-top: 3em">
2828
Accordion Content 2
2929
<p>paragraph</p>
3030
<p>paragraph</p>
@@ -35,7 +35,7 @@ <h3><a href="#">Accordion Header 2</a></h3>
3535
<p>paragraph</p>
3636
</div>
3737
<h3><a href="#">Accordion Header 3</a></h3>
38-
<div>
38+
<div style="padding-top: 0">
3939
Accordion Content 3
4040
<ul>
4141
<li>list item</li>

ui/ui.accordion.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,10 @@ $.widget("ui.accordion", {
216216
maxHeight -= $(this).outerHeight(true);
217217
});
218218

219-
var maxPadding = 0;
220219
this.headers.next().each(function() {
221-
maxPadding = Math.max(maxPadding, $(this).innerHeight() - $(this).height());
222-
}).height(Math.max(0, maxHeight - maxPadding))
223-
.css('overflow', 'auto');
220+
var padding = $(this).innerHeight() - $(this).height();
221+
$(this).height(Math.max(0, maxHeight - padding));
222+
}).css('overflow', 'auto');
224223

225224
} else if ( o.autoHeight ) {
226225
maxHeight = 0;

0 commit comments

Comments
 (0)