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
d5071b19
Commit
d5071b19
authored
Feb 04, 2015
by
Ivan Cheung
Committed by
Chris Rebert
Feb 26, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update all collapse triggers with .collapsed class and aria-expanded
Fixes #15741 Closes #15751 by merging it.
parent
984204c3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
7 deletions
+75
-7
js/collapse.js
js/collapse.js
+4
-4
js/tests/unit/collapse.js
js/tests/unit/collapse.js
+71
-3
No files found.
js/collapse.js
View file @
d5071b19
...
...
@@ -16,7 +16,8 @@
var
Collapse
=
function
(
element
,
options
)
{
this
.
$element
=
$
(
element
)
this
.
options
=
$
.
extend
({},
Collapse
.
DEFAULTS
,
options
)
this
.
$trigger
=
$
(
this
.
options
.
trigger
).
filter
(
'
[href="#
'
+
element
.
id
+
'
"], [data-target="#
'
+
element
.
id
+
'
"]
'
)
this
.
$trigger
=
$
(
'
[data-toggle="collapse"][href="#
'
+
element
.
id
+
'
"],
'
+
'
[data-toggle="collapse"][data-target="#
'
+
element
.
id
+
'
"]
'
)
this
.
transitioning
=
null
if
(
this
.
options
.
parent
)
{
...
...
@@ -33,8 +34,7 @@
Collapse
.
TRANSITION_DURATION
=
350
Collapse
.
DEFAULTS
=
{
toggle
:
true
,
trigger
:
'
[data-toggle="collapse"]
'
toggle
:
true
}
Collapse
.
prototype
.
dimension
=
function
()
{
...
...
@@ -203,7 +203,7 @@
var
$target
=
getTargetFromTrigger
(
$this
)
var
data
=
$target
.
data
(
'
bs.collapse
'
)
var
option
=
data
?
'
toggle
'
:
$
.
extend
({},
$this
.
data
(),
{
trigger
:
this
}
)
var
option
=
data
?
'
toggle
'
:
$
this
.
data
(
)
Plugin
.
call
(
$target
,
option
)
})
...
...
js/tests/unit/collapse.js
View file @
d5071b19
...
...
@@ -80,7 +80,7 @@ $(function () {
$
(
'
<div id="test1"/>
'
)
.
appendTo
(
'
#qunit-fixture
'
)
.
on
(
'
shown.bs.collapse
'
,
function
()
{
assert
.
ok
(
!
$target
.
hasClass
(
'
collapsed
'
))
assert
.
ok
(
!
$target
.
hasClass
(
'
collapsed
'
)
,
'
target does not have collapsed class
'
)
done
()
})
...
...
@@ -95,7 +95,41 @@ $(function () {
$
(
'
<div id="test1" class="in"/>
'
)
.
appendTo
(
'
#qunit-fixture
'
)
.
on
(
'
hidden.bs.collapse
'
,
function
()
{
assert
.
ok
(
$target
.
hasClass
(
'
collapsed
'
))
assert
.
ok
(
$target
.
hasClass
(
'
collapsed
'
),
'
target has collapsed class
'
)
done
()
})
$target
.
click
()
})
QUnit
.
test
(
'
should remove "collapsed" class from all triggers targeting the collapse when the collapse is shown
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
$target
=
$
(
'
<a data-toggle="collapse" class="collapsed" href="#test1"/>
'
).
appendTo
(
'
#qunit-fixture
'
)
var
$alt
=
$
(
'
<a data-toggle="collapse" class="collapsed" href="#test1"/>
'
).
appendTo
(
'
#qunit-fixture
'
)
$
(
'
<div id="test1"/>
'
)
.
appendTo
(
'
#qunit-fixture
'
)
.
on
(
'
shown.bs.collapse
'
,
function
()
{
assert
.
ok
(
!
$target
.
hasClass
(
'
collapsed
'
),
'
target trigger does not have collapsed class
'
)
assert
.
ok
(
!
$alt
.
hasClass
(
'
collapsed
'
),
'
alt trigger does not have collapsed class
'
)
done
()
})
$target
.
click
()
})
QUnit
.
test
(
'
should add "collapsed" class to all triggers targeting the collapse when the collapse is hidden
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
$target
=
$
(
'
<a data-toggle="collapse" href="#test1"/>
'
).
appendTo
(
'
#qunit-fixture
'
)
var
$alt
=
$
(
'
<a data-toggle="collapse" href="#test1"/>
'
).
appendTo
(
'
#qunit-fixture
'
)
$
(
'
<div id="test1" class="in"/>
'
)
.
appendTo
(
'
#qunit-fixture
'
)
.
on
(
'
hidden.bs.collapse
'
,
function
()
{
assert
.
ok
(
$target
.
hasClass
(
'
collapsed
'
),
'
target has collapsed class
'
)
assert
.
ok
(
$alt
.
hasClass
(
'
collapsed
'
),
'
alt trigger has collapsed class
'
)
done
()
})
...
...
@@ -230,6 +264,40 @@ $(function () {
$target
.
click
()
})
QUnit
.
test
(
'
should set aria-expanded="true" on all triggers targeting the collapse when the collapse is shown
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
$target
=
$
(
'
<a data-toggle="collapse" class="collapsed" href="#test1" aria-expanded="false"/>
'
).
appendTo
(
'
#qunit-fixture
'
)
var
$alt
=
$
(
'
<a data-toggle="collapse" class="collapsed" href="#test1" aria-expanded="false"/>
'
).
appendTo
(
'
#qunit-fixture
'
)
$
(
'
<div id="test1"/>
'
)
.
appendTo
(
'
#qunit-fixture
'
)
.
on
(
'
shown.bs.collapse
'
,
function
()
{
assert
.
strictEqual
(
$target
.
attr
(
'
aria-expanded
'
),
'
true
'
,
'
aria-expanded on target is "true"
'
)
assert
.
strictEqual
(
$alt
.
attr
(
'
aria-expanded
'
),
'
true
'
,
'
aria-expanded on alt is "true"
'
)
done
()
})
$target
.
click
()
})
QUnit
.
test
(
'
should set aria-expanded="false" on all triggers targeting the collapse when the collapse is hidden
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
$target
=
$
(
'
<a data-toggle="collapse" href="#test1" aria-expanded="true"/>
'
).
appendTo
(
'
#qunit-fixture
'
)
var
$alt
=
$
(
'
<a data-toggle="collapse" href="#test1" aria-expanded="true"/>
'
).
appendTo
(
'
#qunit-fixture
'
)
$
(
'
<div id="test1" class="in"/>
'
)
.
appendTo
(
'
#qunit-fixture
'
)
.
on
(
'
hidden.bs.collapse
'
,
function
()
{
assert
.
strictEqual
(
$target
.
attr
(
'
aria-expanded
'
),
'
false
'
,
'
aria-expanded on target is "false"
'
)
assert
.
strictEqual
(
$alt
.
attr
(
'
aria-expanded
'
),
'
false
'
,
'
aria-expanded on alt is "false"
'
)
done
()
})
$target
.
click
()
})
QUnit
.
test
(
'
should change aria-expanded from active accordion target to "false" and set the newly active one to "true"
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
...
...
@@ -293,7 +361,7 @@ $(function () {
$target1
.
click
()
setTimeout
(
function
()
{
assert
.
ok
(
!
showFired
,
'
show event did
n
\'
t fire
'
)
assert
.
ok
(
!
showFired
,
'
show event did
no
t fire
'
)
done
()
},
1
)
})
...
...
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