return
}
- const transition = Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE)
-
- if (transition) {
- this._isTransitioning = true
- }
-
const hideEvent = $.Event(Event.HIDE)
$(this._element).trigger(hideEvent)
this._isShown = false
+ const transition = Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE)
+
+ if (transition) {
+ this._isTransitioning = true
+ }
+
this._setEscapeEvent()
this._setResizeEvent()
<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>
$('#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>