Skip to content

Commit 8c9739d

Browse files
committed
Merge pull request twbs#11453 from moodyroto/patch-1
fix scrollspy for targets within tabs
2 parents 7b41aab + 24e3a8b commit 8c9739d

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

js/tests/unit/scrollspy.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,41 @@ $(function () {
3333
ok($topbar.find('.active', true))
3434
})
3535

36+
test("should only switch active class on current target", function () {
37+
var
38+
sectionHTML = '<div id="root" class="active">'
39+
+ '<div class="topbar">'
40+
+ '<div class="topbar-inner">'
41+
+ '<div class="container" id="ss-target">'
42+
+ '<ul class="nav">'
43+
+ '<li><a href="#masthead">Overview</a></li>'
44+
+ '<li><a href="#detail">Detail</a></li>'
45+
+ '</ul>'
46+
+ '</div>'
47+
+ '</div>'
48+
+ '</div>'
49+
+ '<div id="scrollspy-example" style="height: 100px; overflow: auto;">'
50+
+ '<div style="height: 200px;">'
51+
+ '<h4 id="masthead">Overview</h4>'
52+
+ '<p style="height: 200px">'
53+
+ 'Ad leggings keytar, brunch id art party dolor labore.'
54+
+ '</p>'
55+
+ '</div>'
56+
+ '<div style="height: 200px;">'
57+
+ '<h4 id="detail">Detail</h4>'
58+
+ '<p style="height: 200px">'
59+
+ 'Veniam marfa mustache skateboard, adipisicing fugiat velit pitchfork beard.'
60+
+ '</p>'
61+
+ '</div>'
62+
+ '</div>'
63+
+ '</div>'
64+
, $section = $(sectionHTML).appendTo("#qunit-fixture")
65+
, $scrollSpy = $section
66+
.show()
67+
.find("#scrollspy-example")
68+
.scrollspy({target: "#ss-target"})
69+
70+
$scrollSpy.scrollTop(350);
71+
ok($section.hasClass("active"), "Active class still on root node")
72+
})
3673
})

0 commit comments

Comments
 (0)