Commit 75bffd84 authored by Heinrich Fenkart's avatar Heinrich Fenkart

Use closest `.alert` for alert dismissal; closes #14306

parent 14e8ec25
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
if (e) e.preventDefault() if (e) e.preventDefault()
if (!$parent.length) { if (!$parent.length) {
$parent = $this.hasClass('alert') ? $this : $this.parent() $parent = $this.closest('.alert')
} }
$parent.trigger(e = $.Event('close.bs.alert')) $parent.trigger(e = $.Event('close.bs.alert'))
......
...@@ -30,7 +30,7 @@ $(function () { ...@@ -30,7 +30,7 @@ $(function () {
}) })
test('should fade element out on clicking .close', function () { test('should fade element out on clicking .close', function () {
var alertHTML = '<div class="alert-message warning fade in">' var alertHTML = '<div class="alert alert-danger fade in">'
+ '<a class="close" href="#" data-dismiss="alert">×</a>' + '<a class="close" href="#" data-dismiss="alert">×</a>'
+ '<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>' + '<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>'
+ '</div>' + '</div>'
...@@ -42,17 +42,17 @@ $(function () { ...@@ -42,17 +42,17 @@ $(function () {
}) })
test('should remove element when clicking .close', function () { test('should remove element when clicking .close', function () {
var alertHTML = '<div class="alert-message warning fade in">' var alertHTML = '<div class="alert alert-danger fade in">'
+ '<a class="close" href="#" data-dismiss="alert">×</a>' + '<a class="close" href="#" data-dismiss="alert">×</a>'
+ '<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>' + '<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>'
+ '</div>' + '</div>'
var $alert = $(alertHTML).appendTo('#qunit-fixture').bootstrapAlert() var $alert = $(alertHTML).appendTo('#qunit-fixture').bootstrapAlert()
notEqual($('#qunit-fixture').find('.alert-message').length, 0, 'element added to dom') notEqual($('#qunit-fixture').find('.alert').length, 0, 'element added to dom')
$alert.find('.close').click() $alert.find('.close').click()
equal($('#qunit-fixture').find('.alert-message').length, 0, 'element removed from dom') equal($('#qunit-fixture').find('.alert').length, 0, 'element removed from dom')
}) })
test('should not fire closed when close is prevented', function () { test('should not fire closed when close is prevented', function () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment