Skip to content
GitLab
Explore
Projects
Groups
Snippets
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
8e7ba02c
Commit
8e7ba02c
authored
7 years ago
by
Johann-S
Browse files
Options
Download
Email Patches
Plain Diff
Modal plugin set _isTransitioning after the trigger of hide event
parent
da22bce2
8 merge requests
!28721
Hot test
,
!27561
Adds font-weight-medium to font weight classes
,
!25494
web pack
,
!25326
Adjust examples
,
!24514
V4 dev xmr eslint
,
!24390
1
,
!23207
#22402 : modal: new autofocus & keyboardBtnNav options
,
!17021
v4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
js/src/modal.js
+6
-6
js/src/modal.js
js/tests/visual/modal.html
+22
-0
js/tests/visual/modal.html
with
28 additions
and
6 deletions
+28
-6
js/src/modal.js
+
6
-
6
View file @
8e7ba02c
...
...
@@ -169,12 +169,6 @@ const Modal = (() => {
return
}
const
transition
=
Util
.
supportsTransitionEnd
()
&&
$
(
this
.
_element
).
hasClass
(
ClassName
.
FADE
)
if
(
transition
)
{
this
.
_isTransitioning
=
true
}
const
hideEvent
=
$
.
Event
(
Event
.
HIDE
)
$
(
this
.
_element
).
trigger
(
hideEvent
)
...
...
@@ -185,6 +179,12 @@ const Modal = (() => {
this
.
_isShown
=
false
const
transition
=
Util
.
supportsTransitionEnd
()
&&
$
(
this
.
_element
).
hasClass
(
ClassName
.
FADE
)
if
(
transition
)
{
this
.
_isTransitioning
=
true
}
this
.
_setEscapeEvent
()
this
.
_setResizeEvent
()
...
...
This diff is collapsed.
Click to expand it.
js/tests/visual/modal.html
+
22
-
0
View file @
8e7ba02c
...
...
@@ -171,6 +171,12 @@
<button
type=
"button"
class=
"btn btn-secondary btn-lg"
data-toggle=
"modal"
data-target=
"<div class="modal fade the-bad" tabindex="-1" role="dialog"><div class="modal-dialog" role="document"><div class="modal-content"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button><h4 class="modal-title">The Bad Modal</h4></div><div class="modal-body">This modal's HTTML source code is declared inline, inside the data-target attribute of it's show-button</div></div></div></div>"
>
Modal with an XSS inside the data-target
</button>
<br><br>
<button
type=
"button"
class=
"btn btn-secondary btn-lg"
id=
"btnPreventModal"
>
Launch prevented modal on hide (to see the result open your console)
</button>
</div>
<script
src=
"../../../assets/js/vendor/jquery-slim.min.js"
></script>
...
...
@@ -203,6 +209,22 @@
$
(
'
#firefoxModal
'
).
on
(
'
focus
'
,
reportFirefoxTestResult
.
bind
(
false
))
$
(
'
#ff-bug-input
'
).
on
(
'
focus
'
,
reportFirefoxTestResult
.
bind
(
true
))
})
$
(
'
#btnPreventModal
'
).
on
(
'
click
'
,
function
()
{
$
(
'
#firefoxModal
'
).
one
(
'
shown.bs.modal
'
,
function
()
{
$
(
this
).
modal
(
'
hide
'
)
})
.
one
(
'
hide.bs.modal
'
,
function
(
event
)
{
event
.
preventDefault
()
if
(
$
(
this
).
data
(
'
bs.modal
'
).
_isTransitioning
)
{
console
.
error
(
'
Modal plugin should not set _isTransitioning when hide event is prevented
'
)
}
else
{
console
.
log
(
'
Test passed
'
)
$
(
this
).
modal
(
'
hide
'
)
// work as expected
}
})
.
modal
(
'
show
'
)
})
})
</script>
</body>
...
...
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
Menu
Explore
Projects
Groups
Snippets