#10709 closed defect (fixed)
dojo.extend doesn not extend properly constructors produced by dojo.declare
Reported by: | Jacco Compier | Owned by: | Eugene Lazutkin |
---|---|---|---|
Priority: | high | Milestone: | 1.5 |
Component: | Core | Version: | 1.4.0 |
Keywords: | C3 Multiple inheritance extend | Cc: | |
Blocked By: | Blocking: |
Description
The new C3 method resolution has some bugs in it. When a class is declared using multiple inheritance, only the first class is fully included in the declared class. Extended properties are not included!
An example is included below to make things clearer. abc.B2 and abc.C2 return "undefined" but should return a value.
I've looked at the source code and it seems that dojo.extend doesn't add properties to the _meta.hidden object of the class. Other methods like safeMixin and _mixin have the same problem.
Example:
dojo.declare ( 'test.a', null, { A1:'A1' } ); dojo.declare ( 'test.b', null, { B1:'B1' } ); dojo.declare ( 'test.c', null, { C1:'C1' } ); dojo.extend ( test.a, { A2: 'A2' } ); dojo.extend ( test.b, { B2: 'B2' } ); dojo.extend ( test.c, { C2: 'C2' } ); dojo.declare ( 'test.abc', [test.a,test.b,test.c], { } ); var abc = new test.abc(); alert(abc.A1+' - '+abc.B1+' - '+abc.C1+' - '+abc.A2+' - '+abc.B2+' - '+abc.C2);
Attachments (1)
Change History (8)
comment:1 Changed 11 years ago by
Owner: | changed from anonymous to Eugene Lazutkin |
---|
comment:2 Changed 11 years ago by
Milestone: | tbd → 1.5 |
---|---|
Priority: | high → normal |
Status: | new → assigned |
comment:4 Changed 11 years ago by
Summary: | C3 Multiple inheritance doesn't work correctly when extending classes → dojo.extend doesn not extend properly constructors produced by dojo.declare |
---|
dojo.extend()
doesn't know about dojo.declare()
intentionally.
dojo.declare()
provides another mechanism to extend classes --- Class.extend()
, which is defined on every class.
Rewriting your example:
dojo.declare ( 'test.a', null, { A1:'A1' } ); dojo.declare ( 'test.b', null, { B1:'B1' } ); dojo.declare ( 'test.c', null, { C1:'C1' } ); test.a.extend( { A2: 'A2' } ); test.b.extend( { B2: 'B2' } ); test.c.extend( { C2: 'C2' } ); dojo.declare ( 'test.abc', [test.a,test.b,test.c], { } ); var abc = new test.abc(); alert(abc.A1+' - '+abc.B1+' - '+abc.C1+' - '+abc.A2+' - '+abc.B2+' - '+abc.C2);
comment:5 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:6 Changed 11 years ago by
I corrected the bug and explained the behavior in http://docs.dojocampus.org/dojo/declare
Not sure if this is supposed to be supported or not, there might be an extend method in classes created by dojo.declare() that you need to call. Anyway, assigning to Eugene.