Opened 11 years ago

Closed 11 years ago

#6965 closed defect (fixed)

Error: w.destroy is not a function

Reported by: guest Owned by: alex
Priority: high Milestone: 1.2
Component: Dijit Version: 1.1.1
Keywords: Cc:
Blocked By: Blocking:


My widget template contains the following:

<div dojoType="" jsId="pdiTrustStore" url="/imr/options.dojo?bean=pdiTrustOptions&value=identity"></div>

This works fine in dojo 1.0.2, but 1.1.1 generates an error when the widget is destroyed:

w.destroy is not a function

/imr/js/dojo-release-1.1.1/dojo/../dijit/_Widget.js Line 208

I believe w.destroy() (in destroy() in _Widget.js) should be called only if the widget contains the destroy method.

destroy widgets created as part of template, etc.

[], function(w){ w.destroy(); });

Please help how to handle this error.

Change History (4)

comment:1 Changed 11 years ago by nathan

I have encountered this error - and it's actually quite helpful to have the destroy function behave as it currently does. I have found many times where I was not properly cleaning up things.

I would suggest *NOT* putting non-widget declarations within a widget template. In this case, you can accomplish the same thing by just creating an ItemFileReadStore? in your postCreate function of your widget:

postCreate: function(){
    this.pdiTrustStore = new{url: "/imr/options.dojo?bean=bdiTrustOptions&value=identity"});

If you need this *before* other widgets are created, you could put it in your postMixInProperties function instead.

That would keep your widget from trying to call destroy() on the store - since the store really *isn't* a widget.

comment:2 Changed 11 years ago by alex

Milestone: 1.2
Owner: set to alex
Priority: highestnormal
severity: blockermajor
Status: newassigned

comment:3 Changed 11 years ago by alex


I think it's reasonable to assume that what you can declare in markup regularly you should be able to do in a template, and insofar as this is clearly a regression, it should be fixed on that basis alone. Dojo's markup system supports creating all kinds of classes declaratively, including things that aren't "widgets"...that's a feature, not a bug, and something we need to fix.


comment:4 Changed 11 years ago by alex

Resolution: fixed
Status: assignedclosed

(In [14060]) updating destruction code to handle the case where a child or declared item may not have a "destroy" method. Updating documentation, some code size reductions. Fixes #6965. !strict

Note: See TracTickets for help on using tickets.