Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#8806 closed defect (fixed)

[patch] [cla] _onConnect for _Widget leads to unwanted connect

Reported by: jfcunat Owned by: bill
Priority: high Milestone: 1.3
Component: Dijit Version: 1.3.0b2
Keywords: Cc:
Blocked By: Blocking:

Description

When the _onConnect function is called, some connects are done on the Object methods contructor and toString. These are surely not wanted.

This is because of the loop in _Widget.create

for(attr in this.params){

this._onConnect(attr);

}

where attr can be contructor or toString (at least on FF3 and Safari 3.2.2)

Attachments (2)

Widget_onConnect.patch (620 bytes) - added by jfcunat 10 years ago.
Widget_onConnect2.patch (576 bytes) - added by jfcunat 10 years ago.
test would be better there as it won't call _onConnect with contructor and toString at all

Download all attachments as: .zip

Change History (9)

Changed 10 years ago by jfcunat

Attachment: Widget_onConnect.patch added

Changed 10 years ago by jfcunat

Attachment: Widget_onConnect2.patch added

test would be better there as it won't call _onConnect with contructor and toString at all

comment:1 Changed 10 years ago by bill

Owner: set to bill
Priority: highnormal
Status: newassigned
Summary: _onConnect for _Widget leads to unwanted connect[patch] [cla] _onConnect for _Widget leads to unwanted connect

comment:2 Changed 10 years ago by bill

severity: majorminor

comment:3 Changed 10 years ago by bill

Hmm, this is confusing, I tried some code like this:

var obj = {foo: "bar"};
for(var i in obj){
  console.log("found: " + i);
}

and for FF3 at least, it only prints "foo".

Regarding your patch2, it doesn't work... for(attr in this.params && !(attr in {})) is not valid javascript since attr in this.params is not a condition (like in an if() statement) but rather a special syntax for making for() loop over everything in this.params.

comment:4 Changed 10 years ago by bill

(In [16925]) Test case for deferred connections (refs #8806)

comment:5 Changed 10 years ago by bill

Oh, the actual problem is in the parser: it's adding constructor and toString() into the params object. I'll fix. Hopefully there's never a case where either of those words is the name of an actual widget parameter.

BTW see also #8814 for a related bug I found along the way.

comment:6 Changed 10 years ago by bill

Resolution: fixed
Status: assignedclosed

(In [16927]) Parser was putting "constructor" and "toString" into the params passed to every widget. This in turn was causing Widget to do two unnecessary (and meaningless) dojo.connect() calls.

Fixes #8806 !strict.

comment:7 Changed 10 years ago by bill

(In [16930]) Testcase that parser doesn't pass unwanted parameters to a widget. Refs #8806 !strict.

Note: See TracTickets for help on using tickets.