Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Bootstrap
bootstrap
Commits
fc15c4c4
Commit
fc15c4c4
authored
6 years ago
by
Mike Vastola
Committed by
XhmikosR
6 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Change button checkbox/radios to ignore hidden input fields (#27802)
parent
385ce1c9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
js/src/button.js
+1
-1
js/src/button.js
js/tests/unit/button.js
+23
-0
js/tests/unit/button.js
with
24 additions
and
1 deletion
+24
-1
js/src/button.js
+
1
-
1
View file @
fc15c4c4
...
@@ -29,7 +29,7 @@ const ClassName = {
...
@@ -29,7 +29,7 @@ const ClassName = {
const
Selector
=
{
const
Selector
=
{
DATA_TOGGLE_CARROT
:
'
[data-toggle^="button"]
'
,
DATA_TOGGLE_CARROT
:
'
[data-toggle^="button"]
'
,
DATA_TOGGLE
:
'
[data-toggle="buttons"]
'
,
DATA_TOGGLE
:
'
[data-toggle="buttons"]
'
,
INPUT
:
'
input
'
,
INPUT
:
'
input
:not([type="hidden"])
'
,
ACTIVE
:
'
.active
'
,
ACTIVE
:
'
.active
'
,
BUTTON
:
'
.btn
'
BUTTON
:
'
.btn
'
}
}
...
...
This diff is collapsed.
Click to expand it.
js/tests/unit/button.js
+
23
-
0
View file @
fc15c4c4
...
@@ -139,6 +139,29 @@ $(function () {
...
@@ -139,6 +139,29 @@ $(function () {
assert
.
ok
(
$btn2
.
find
(
'
input
'
).
prop
(
'
checked
'
),
'
btn2 is checked
'
)
assert
.
ok
(
$btn2
.
find
(
'
input
'
).
prop
(
'
checked
'
),
'
btn2 is checked
'
)
})
})
QUnit
.
test
(
'
should only toggle selectable inputs
'
,
function
(
assert
)
{
assert
.
expect
(
6
)
var
groupHTML
=
'
<div class="btn-group" data-toggle="buttons">
'
+
'
<label class="btn btn-primary active">
'
+
'
<input type="hidden" name="option1" id="option1-default" value="false">
'
+
'
<input type="checkbox" name="option1" id="option1" checked="true"> Option 1
'
+
'
</label>
'
+
'
</div>
'
var
$group
=
$
(
groupHTML
).
appendTo
(
'
#qunit-fixture
'
)
var
$btn
=
$group
.
children
().
eq
(
0
)
var
$hidden
=
$btn
.
find
(
'
input#option1-default
'
)
var
$cb
=
$btn
.
find
(
'
input#option1
'
)
assert
.
ok
(
$btn
.
hasClass
(
'
active
'
),
'
btn has active class
'
)
assert
.
ok
(
$cb
.
prop
(
'
checked
'
),
'
btn is checked
'
)
assert
.
ok
(
!
$hidden
.
prop
(
'
checked
'
),
'
hidden is not checked
'
)
$btn
.
trigger
(
'
click
'
)
assert
.
ok
(
!
$btn
.
hasClass
(
'
active
'
),
'
btn does not have active class
'
)
assert
.
ok
(
!
$cb
.
prop
(
'
checked
'
),
'
btn is not checked
'
)
assert
.
ok
(
!
$hidden
.
prop
(
'
checked
'
),
'
hidden is not checked
'
)
// should not be changed
})
QUnit
.
test
(
'
should not add aria-pressed on labels for radio/checkbox inputs in a data-toggle="buttons" group
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should not add aria-pressed on labels for radio/checkbox inputs in a data-toggle="buttons" group
'
,
function
(
assert
)
{
assert
.
expect
(
2
)
assert
.
expect
(
2
)
var
groupHTML
=
'
<div class="btn-group" data-toggle="buttons">
'
+
var
groupHTML
=
'
<div class="btn-group" data-toggle="buttons">
'
+
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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