From: Heinrich Fenkart Date: Mon, 5 May 2014 10:11:59 +0000 (+0200) Subject: Allow for resetText of a button to be a falsey value; fixes #13466 X-Git-Tag: v3.2.0~193^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F13511%2Fhead;p=thirdparty%2Fbootstrap.git Allow for resetText of a button to be a falsey value; fixes #13466 --- diff --git a/js/button.js b/js/button.js index b359a6ec62..bbce6690e8 100644 --- a/js/button.js +++ b/js/button.js @@ -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 () { diff --git a/js/tests/unit/button.js b/js/tests/unit/button.js index 10bff14429..da65ae3837 100644 --- a/js/tests/unit/button.js +++ b/js/tests/unit/button.js @@ -57,7 +57,27 @@ $(function () { start() }, 0) }, 0) + }) + test('should work with an empty string as reset state', function () { + var btn = $('') + 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 () {