mirror of
https://github.com/twbs/bootstrap.git
synced 2022-11-09 12:25:43 -05:00
prevent navigating to area href when modal target. fixes #18796
This commit is contained in:
parent
0416f761dd
commit
bfa714ae1e
2 changed files with 23 additions and 1 deletions
|
@ -491,7 +491,7 @@ const Modal = (($) => {
|
|||
let config = $(target).data(DATA_KEY) ?
|
||||
'toggle' : $.extend({}, $(target).data(), $(this).data())
|
||||
|
||||
if (this.tagName === 'A') {
|
||||
if (this.tagName === 'A' || this.tagName === 'AREA') {
|
||||
event.preventDefault()
|
||||
}
|
||||
|
||||
|
|
|
@ -403,4 +403,26 @@ $(function () {
|
|||
})
|
||||
.bootstrapModal('show')
|
||||
})
|
||||
|
||||
QUnit.test('should not follow link in area tag', function (assert) {
|
||||
assert.expect(2)
|
||||
var done = assert.async()
|
||||
|
||||
$('<map><area id="test" shape="default" data-toggle="modal" data-target="#modal-test" href="demo.html"/></map>')
|
||||
.appendTo('#qunit-fixture')
|
||||
|
||||
$('<div id="modal-test"><div class="contents"><div id="close" data-dismiss="modal"/></div></div>')
|
||||
.appendTo('#qunit-fixture')
|
||||
|
||||
$('#test')
|
||||
.on('click.bs.modal.data-api', function (event) {
|
||||
assert.notOk(event.isDefaultPrevented(), 'navigating to href will happen')
|
||||
|
||||
setTimeout(function () {
|
||||
assert.ok(event.isDefaultPrevented(), 'model shown instead of navigating to href')
|
||||
done()
|
||||
}, 1)
|
||||
})
|
||||
.trigger('click')
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue