Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#10605 closed defect (fixed)

dijit.form.Textarea doesn't clear _setTimeoutHandle when destroyed

Reported by: robg Owned by: Douglas Hays
Priority: high Milestone: 1.5
Component: Dijit - Form Version: 1.4.0
Keywords: Cc:
Blocked By: Blocking:

Description

When _onInput fires, Textarea sets a callback to _shrink on a timeout (line 71-76 in Textarea.js). When the widget is destroyed, it doesn't clear that timeout so in some cases the browser attempts to fire _shrink on an already-destroyed widget, which results in an error message of 'textarea not found', from line 92 in Textarea.js.

To repro in FF 3.5.7, from a page that includes dojo:

<script type="text/javascript">
dojo.require("dijit.form.Textarea");
dojo.addOnLoad(function () {
  dojo.global.k = new dijit.form.Textarea();
  k.placeAt(dojo.body(), 'last');
  console.log("Done");
});
</script>

then in the firebug console, type:

k.attr('value', 'bar'); k.destroyRecursive();

(it's important that they be executed at the same time)

It's also possible to reproduce the bug without using the firebug console - when it shows up in my code, it shows up without the console - but it's simpler to reproduce this way.

One possible solution to the issue is to add an uninitialize() method to Textarea.js, e.g.:

uninitialize: function(){
  if (this._setTimeoutHandle){
    clearTimeout(this._setTimeoutHandle);
  }
  this.inherited(arguments);
}

This fixes the issue for me.

Change History (5)

comment:1 Changed 9 years ago by robg

I also noticed that doing

new dijit.form.Textarea().destroyRecursive();

results in a similar timing bug (due to the setTimeout in Textarea.postCreate (line137). But it's probably very unlikely to cause issues.

comment:2 Changed 9 years ago by bill

Owner: set to Douglas Hays

comment:3 Changed 9 years ago by Douglas Hays

Milestone: tbd1.5

comment:4 Changed 9 years ago by Douglas Hays

Resolution: fixed
Status: newclosed

(In [21273]) Fixes #10605. Clear settimeout handle during widget teardown

comment:5 Changed 8 years ago by bill

Component: DijitDijit - Form
Note: See TracTickets for help on using tickets.