diff options
| author | Chris Rebert <[email protected]> | 2014-05-05 22:55:05 -0700 |
|---|---|---|
| committer | Chris Rebert <[email protected]> | 2014-05-05 22:55:05 -0700 |
| commit | 9444df247698f65df05e345f525c14fbf14aead6 (patch) | |
| tree | 3d2ed5cfe88ca2d959f38997b60108398b138ad9 | |
| parent | a032c396ee5bc850b2813978fcac54071b19d3a4 (diff) | |
| parent | d8ee1ba9b61ef4ba5b0494433e3a6eac414ef782 (diff) | |
| download | bootstrap-9444df247698f65df05e345f525c14fbf14aead6.tar.xz bootstrap-9444df247698f65df05e345f525c14fbf14aead6.zip | |
Merge pull request #13511 from hnrch02/button-reset-falsey-values-fix
Allow for resetText of a button to be a falsey value; fixes #13466
| -rw-r--r-- | js/button.js | 4 | ||||
| -rw-r--r-- | js/tests/unit/button.js | 20 |
2 files changed, 22 insertions, 2 deletions
diff --git a/js/button.js b/js/button.js index b359a6ec6..bbce6690e 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 10bff1442..da65ae383 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 = $('<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 () { |
