Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bootstrap
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
bootstrap
Commits
21d56378
Commit
21d56378
authored
Mar 09, 2015
by
Chris Rebert
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16011 from twbs/fix-15315
.collapse('hide') on hidden uninit-ed collapsible no longer shows it
parents
2c56b0fe
5c8d56d5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
5 deletions
+32
-5
js/collapse.js
js/collapse.js
+1
-1
js/tests/unit/collapse.js
js/tests/unit/collapse.js
+31
-4
No files found.
js/collapse.js
View file @
21d56378
...
@@ -172,7 +172,7 @@
...
@@ -172,7 +172,7 @@
var
data
=
$this
.
data
(
'
bs.collapse
'
)
var
data
=
$this
.
data
(
'
bs.collapse
'
)
var
options
=
$
.
extend
({},
Collapse
.
DEFAULTS
,
$this
.
data
(),
typeof
option
==
'
object
'
&&
option
)
var
options
=
$
.
extend
({},
Collapse
.
DEFAULTS
,
$this
.
data
(),
typeof
option
==
'
object
'
&&
option
)
if
(
!
data
&&
options
.
toggle
&&
option
==
'
show
'
)
options
.
toggle
=
false
if
(
!
data
&&
options
.
toggle
&&
/show|hide/
.
test
(
option
)
)
options
.
toggle
=
false
if
(
!
data
)
$this
.
data
(
'
bs.collapse
'
,
(
data
=
new
Collapse
(
this
,
options
)))
if
(
!
data
)
$this
.
data
(
'
bs.collapse
'
,
(
data
=
new
Collapse
(
this
,
options
)))
if
(
typeof
option
==
'
string
'
)
data
[
option
]()
if
(
typeof
option
==
'
string
'
)
data
[
option
]()
})
})
...
...
js/tests/unit/collapse.js
View file @
21d56378
...
@@ -41,11 +41,10 @@ $(function () {
...
@@ -41,11 +41,10 @@ $(function () {
})
})
QUnit
.
test
(
'
should hide a collapsed element
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should hide a collapsed element
'
,
function
(
assert
)
{
assert
.
expect
(
2
)
assert
.
expect
(
1
)
var
$el
=
$
(
'
<div class="collapse"/>
'
).
bootstrapCollapse
(
'
hide
'
)
var
$el
=
$
(
'
<div class="collapse"/>
'
).
bootstrapCollapse
(
'
hide
'
)
assert
.
ok
(
!
$el
.
hasClass
(
'
in
'
),
'
does not have class "in"
'
)
assert
.
ok
(
!
$el
.
hasClass
(
'
in
'
),
'
does not have class "in"
'
)
assert
.
ok
(
/height/i
.
test
(
$el
.
attr
(
'
style
'
)),
'
has height set
'
)
})
})
QUnit
.
test
(
'
should not fire shown when show is prevented
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should not fire shown when show is prevented
'
,
function
(
assert
)
{
...
@@ -147,7 +146,7 @@ $(function () {
...
@@ -147,7 +146,7 @@ $(function () {
$target
.
click
()
$target
.
click
()
})
})
QUnit
.
test
(
'
should not close a collapse when initialized with "show" if already shown
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should not close a collapse when initialized with "show"
option
if already shown
'
,
function
(
assert
)
{
assert
.
expect
(
0
)
assert
.
expect
(
0
)
var
done
=
assert
.
async
()
var
done
=
assert
.
async
()
...
@@ -162,7 +161,7 @@ $(function () {
...
@@ -162,7 +161,7 @@ $(function () {
setTimeout
(
done
,
0
)
setTimeout
(
done
,
0
)
})
})
QUnit
.
test
(
'
should open a collapse when initialized with "show" if not already shown
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should open a collapse when initialized with "show"
option
if not already shown
'
,
function
(
assert
)
{
assert
.
expect
(
1
)
assert
.
expect
(
1
)
var
done
=
assert
.
async
()
var
done
=
assert
.
async
()
...
@@ -177,6 +176,34 @@ $(function () {
...
@@ -177,6 +176,34 @@ $(function () {
setTimeout
(
done
,
0
)
setTimeout
(
done
,
0
)
})
})
QUnit
.
test
(
'
should not show a collapse when initialized with "hide" option if already hidden
'
,
function
(
assert
)
{
assert
.
expect
(
0
)
var
done
=
assert
.
async
()
$
(
'
<div class="collapse"></div>
'
)
.
appendTo
(
'
#qunit-fixture
'
)
.
on
(
'
show.bs.collapse
'
,
function
()
{
assert
.
ok
(
false
,
'
showing a previously-uninitialized hidden collapse when the "hide" method is called
'
)
})
.
bootstrapCollapse
(
'
hide
'
)
setTimeout
(
done
,
0
)
})
QUnit
.
test
(
'
should hide a collapse when initialized with "hide" option if not already hidden
'
,
function
(
assert
)
{
assert
.
expect
(
1
)
var
done
=
assert
.
async
()
$
(
'
<div class="collapse in"></div>
'
)
.
appendTo
(
'
#qunit-fixture
'
)
.
on
(
'
hide.bs.collapse
'
,
function
()
{
assert
.
ok
(
true
,
'
hiding a previously-uninitialized shown collapse when the "hide" method is called
'
)
})
.
bootstrapCollapse
(
'
hide
'
)
setTimeout
(
done
,
0
)
})
QUnit
.
test
(
'
should remove "collapsed" class from active accordion target
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should remove "collapsed" class from active accordion target
'
,
function
(
assert
)
{
assert
.
expect
(
3
)
assert
.
expect
(
3
)
var
done
=
assert
.
async
()
var
done
=
assert
.
async
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment