Opened 10 years ago

Closed 10 years ago

#9367 closed defect (invalid)

#5252 resurrection

Reported by: Aleksey Rechinskiy Owned by: dante
Priority: high Milestone: 1.4
Component: Dijit Version: 1.3.1
Keywords: Cc:
Blocked By: Blocking:

Description

Hi all! It seems that #5252 is reappeared in (at least) dojo 1.3.1. Check the test case: http://bugs.dojotoolkit.org/attachment/ticket/5252/test.html - startup fires twice!

Change History (5)

comment:1 Changed 10 years ago by Aleksey Rechinskiy

Oops, I forgot about:

this.inherited(arguments);

and the test case is also lacks of that statement...

It's my fault, sorry to bother.

comment:2 Changed 10 years ago by bill

Owner: set to dante

Hmm I don't see how forgetting this.inherited(arguments) could make startup() get called twice.

I think this will be fixed as part of #9348 though, so assigning to dante.

comment:3 Changed 10 years ago by Aleksey Rechinskiy

Mmmm.... I'm not sure if I'm right just because I don't know the dojo's architecture as good as you, but as I understand from a code, dijit._widget's startup function sets a flag this._started = true; When it is called by this.inherited(arguments), it changes the flag and such prevents widget startup function to be called next time by a parser (parser checks the widgets _started flag in instantiate() function when it deciding if it should call startup()).

The test case as specified in http://bugs.dojotoolkit.org/attachment/ticket/5252/test.html doesn't make a call to this.inherited(arguments). If one changes the test to

dojo.addOnLoad(function() {
    dojo.declare("foo.Button", dijit._Widget, {
        startup: function() {
           alert("Button.startup");

           // ADD THIS LINE
           this.inherited(arguments);
        }
    });

    dojo.declare("foo.Dialog", [dijit._Widget, dijit._Templated], {
	widgetsInTemplate: true,
	templateString:
	    "<div>" +
	    "	<div dojoType='dijit.layout.LayoutContainer'>" +
	    "		<div dojoType='foo.Button' layoutAlign='client'></div>" +
	    "	</div>" +
	    "</div>"
    });

    var dlg = new foo.Dialog();
});

It would work as expected, startup will be called only once.

I think, you know better, if this ticket is related to #9348, but mmmm.... Am I missing something in my explanation? There should be no call to this.inherited(arguments) ?

comment:4 Changed 10 years ago by Aleksey Rechinskiy

Hmm I don't see how forgetting this.inherited(arguments) could make startup() get called twice.

I mean, it could be called twice (or more), because widget's _started flag is not set.

comment:5 Changed 10 years ago by bill

Resolution: invalid
Status: newclosed

Ah yes, you are right. OK, I'll close this ticket then. I don't think this ticket is related to #9348, although it's a good reminder to make sure that the changes for #9348 don't cause submit() to get called twice again.

Note: See TracTickets for help on using tickets.