diff --git a/List.js b/List.js index 3899883e0..3fd72620a 100644 --- a/List.js +++ b/List.js @@ -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: diff --git a/test/intern/core/createDestroy.js b/test/intern/core/createDestroy.js index 0a62b85a2..0d91fee82 100644 --- a/test/intern/core/createDestroy.js +++ b/test/intern/core/createDestroy.js @@ -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'); + }); }); }); \ No newline at end of file