Skip to content

Commit

Permalink
Fix #867: List: Don't call inherited destroy if useTouchScroll is false
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenneth G. Franqueiro committed Mar 7, 2014
1 parent e957549 commit bea918f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
6 changes: 5 additions & 1 deletion List.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,11 @@ function(kernel, declare, dom, listen, has, miscUtil, TouchScroll, hasClass, put
this.cleanup();
// destroy DOM
put(this.domNode, "!");
this.inherited(arguments);

if(this.useTouchScroll){
// Only call TouchScroll#destroy if we also initialized it
this.inherited(arguments);
}
},
refresh: function(){
// summary:
Expand Down
24 changes: 15 additions & 9 deletions test/intern/core/createDestroy.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
define([
"intern!tdd",
"intern/chai!assert",
"dojo/_base/declare",
"dgrid/List",
"dgrid/Grid",
"dgrid/editor",
"dgrid/TouchScroll",
"dijit/registry",
"dijit/form/TextBox",
"dgrid/test/data/base"
], function (test, assert, List, Grid, editor, registry, TextBox) {
], function (test, assert, declare, List, TouchScroll, registry, TextBox) {

test.suite("createDestroy", function(){
// Tests
test.test("no params list", function(){
// build a list, start it up, and render
var list = new List();
document.body.appendChild(list.domNode);
list.startup();
list.renderArray([ "foo", "bar", "baz" ]);

// check number of children

assert.strictEqual(list.contentNode.children.length, 3,
"List's contentNode has expected number of children after renderArray");

// kill it & make sure we are all cleaned up

list.destroy();
assert.notStrictEqual(document.body, list.parentNode,
"List is removed from body after destroy");
});

test.test("TouchScroll with useTouchScroll: false", function(){
// Ensure TouchScroll is inherited for this test
var list = new (declare([TouchScroll, List]))({ useTouchScroll: false });

// This should not cause an error
assert.doesNotThrow(function(){
list.destroy();
}, null, 'destroy should not throw error');
});
});
});

0 comments on commit bea918f

Please sign in to comment.