From 8539bc8d63409b36d408131db7a2800c30e668f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20G=C3=A9linas?= Date: Thu, 17 Oct 2013 10:34:51 -0400 Subject: [PATCH] Fixed issue #169: removed usage of falsy value in if and prefer equality testing with empty string. --- js/bootstrap-timepicker.js | 4 ++-- spec/js/TimepickerSpec.js | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/js/bootstrap-timepicker.js b/js/bootstrap-timepicker.js index 8ea48d8f..e12a4e5f 100644 --- a/js/bootstrap-timepicker.js +++ b/js/bootstrap-timepicker.js @@ -318,7 +318,7 @@ }, getTime: function() { - if (!this.hour && !this.minute && !this.second) { + if (this.hour === '') { return ''; } @@ -818,7 +818,7 @@ } // widget shouldn't be empty on open - if (!this.hour) { + if (this.hour === '') { if (this.defaultTime) { this.setDefaultTime(this.defaultTime); } else { diff --git a/spec/js/TimepickerSpec.js b/spec/js/TimepickerSpec.js index ad0f2371..e6c601b9 100644 --- a/spec/js/TimepickerSpec.js +++ b/spec/js/TimepickerSpec.js @@ -217,6 +217,8 @@ describe('Timepicker feature', function() { tp3.setTime('2320'); expect(tp3.getTime()).toBe('23:20:00', 'setTime with 2320 on tp3'); + tp3.setTime('0:00'); + expect(tp3.getTime()).toBe('0:00:00', 'setTime with 0:00 on tp3'); }); it('should update picker on blur', function() {