]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Use closest `.alert` for alert dismissal; closes #14306 14316/head
authorHeinrich Fenkart <hnrch02@gmail.com>
Mon, 4 Aug 2014 17:33:42 +0000 (19:33 +0200)
committerHeinrich Fenkart <hnrch02@gmail.com>
Mon, 4 Aug 2014 17:33:42 +0000 (19:33 +0200)
js/alert.js
js/tests/unit/alert.js

index 5389c32e9954b070060410ad1ed3d649c1e1c8cc..10483899dff5392b31054cd9e6c2551dc340d02e 100644 (file)
@@ -36,7 +36,7 @@
     if (e) e.preventDefault()
 
     if (!$parent.length) {
-      $parent = $this.hasClass('alert') ? $this : $this.parent()
+      $parent = $this.closest('.alert')
     }
 
     $parent.trigger(e = $.Event('close.bs.alert'))
index 52505c828d429aac9b83bcc6d8ba7be3a5294843..bc4eed67650cd6a4dbe5bdb0c1658c29002dfd19 100644 (file)
@@ -30,7 +30,7 @@ $(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>'
         + '<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>'
         + '</div>'
@@ -42,17 +42,17 @@ $(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>'
         + '<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>'
         + '</div>'
     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()
 
-    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 () {