]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Allow for resetText of a button to be a falsey value; fixes #13466 13511/head
authorHeinrich Fenkart <hnrch02@gmail.com>
Mon, 5 May 2014 10:11:59 +0000 (12:11 +0200)
committerHeinrich Fenkart <hnrch02@gmail.com>
Mon, 5 May 2014 17:07:47 +0000 (19:07 +0200)
js/button.js
js/tests/unit/button.js

index b359a6ec627776999d49c622a04fa7d0e34b9af2..bbce6690e83dfcde4fc632f3f951e6cc9a39df3b 100644 (file)
@@ -31,9 +31,9 @@
 
     state = state + 'Text'
 
-    if (!data.resetText) $el.data('resetText', $el[val]())
+    if (data.resetText == null) $el.data('resetText', $el[val]())
 
-    $el[val](data[state] || this.options[state])
+    $el[val](data[state] == null ? this.options[state] : data[state])
 
     // push to event loop to allow forms to submit
     setTimeout($.proxy(function () {
index 10bff144291abf5a34a2f71dfe5c7cc168d3c0a9..da65ae3837d10a1c41f40fb94373043c29f7b5eb 100644 (file)
@@ -57,7 +57,27 @@ $(function () {
         start()
       }, 0)
     }, 0)
+  })
 
+  test('should work with an empty string as reset state', function () {
+    var btn = $('<button class="btn" data-loading-text="fat"></button>')
+    equal(btn.html(), '', 'btn text equals ""')
+    btn.bootstrapButton('loading')
+    equal(btn.html(), 'fat', 'btn text equals fat')
+    stop()
+    setTimeout(function () {
+      ok(btn.attr('disabled'), 'btn is disabled')
+      ok(btn.hasClass('disabled'), 'btn has disabled class')
+      start()
+      stop()
+      btn.bootstrapButton('reset')
+      equal(btn.html(), '', 'btn text equals ""')
+      setTimeout(function () {
+        ok(!btn.attr('disabled'), 'btn is not disabled')
+        ok(!btn.hasClass('disabled'), 'btn does not have disabled class')
+        start()
+      }, 0)
+    }, 0)
   })
 
   test('should toggle active', function () {