Browse files

Fixes #1081 - calling .empty() an already empty HtmlTable instance

  • Loading branch information...
1 parent 8d9dfe6 commit f55c257c6237723d5bc70e0f7261af839b0f1e77 @anutron anutron committed Mar 25, 2012
Showing with 17 additions and 1 deletion.
  1. +1 −1 Source/Interface/HtmlTable.Select.js
  2. +16 −0 Tests/Specs/1.3/Interface/HtmlTable.js
View
2 Source/Interface/HtmlTable.Select.js
@@ -58,7 +58,7 @@ HtmlTable = Class.refactor(HtmlTable, {
},
empty: function(){
- this.selectNone();
+ if (this.body.rows.length) this.selectNone();
return this.previous();
},
View
16 Tests/Specs/1.3/Interface/HtmlTable.js
@@ -137,6 +137,22 @@ describe('HtmlTable', function(){
});
+ describe('HtmlTable:empty', function(){
+
+ it('should empty a table', function(){
+ var table = new HtmlTable();
+ table.push(['hello','world']);
+ table.push(['hello','world again']);
+ expect(table.body.rows.length).toEqual(2);
+ table.empty();
+ expect(table.body.rows.length).toEqual(0);
+ table.empty();
+ expect(table.body.rows.length).toEqual(0);
+ });
+
+ });
+
+
describe('HtmlTable cloned Element methods', function(){
var t = new HtmlTable({

1 comment on commit f55c257

@jfly

Is this really the best fix? Shouldn't selectNone() work when called on an empty table?

Please sign in to comment.