Opened 7 years ago

Closed 6 years ago

Last modified 6 years ago

#16505 closed enhancement (fixed)

dojo.declare()'s createSubclass() features, tests, and docs

Reported by: bill Owned by: cjolif
Priority: undecided Milestone: 1.9
Component: Core Version: 1.8.2
Keywords: Cc: ben hockey
Blocked By: Blocking:

Description

dojo.declare()'s createSubclass() added in [27667] is awkward to use to add new methods to the new class. You need to do:

var MyClass = BaseClass.createSubclass([A, B]);
MyClass.extend({
   newMethod: function(){ ... }
});

rather than what I would expect:

var MyClass = BaseClass.createSubclass([A, B], {
   newMethod: function(){ ... }
});

A fuller test case is:

var MyMixin = dojo.declare(null, {
   postCreate: function(){
       this.inherited(arguments);
       console.log("MyMixin postCreate");
   }
});
var MyMenu = dijit.Menu.createSubclass(MyMixin, {
   postCreate: function(){
       this.inherited(arguments);
       console.log("MyMenu postCreate");
   }
});
new MyMenu();

Also, it should have some tests, and documentation in the reference guide.

Attachments (1)

16505.patch (3.0 KB) - added by cjolif 7 years ago.
possible patch to implement props argument in createSubclass, add inline doc and tests

Download all attachments as: .zip

Change History (8)

comment:1 Changed 7 years ago by bill

Owner: set to cjolif
Status: newassigned

comment:2 Changed 7 years ago by ben hockey

Cc: ben hockey added

comment:4 Changed 7 years ago by cjolif

Milestone: tbd1.9

To be honest I did add this method mostly for the profit of the parser (data-dojo-mixins), not necessarily thinking about end-users using it as well directly, thus the lack of doc. Note that even if there is no direct tests it is tested through the parser tests which uses it.

That said you are right it certainly makes sense to add direct tests, docs and improve API. I'll try to do that for 1.9.

Changed 7 years ago by cjolif

Attachment: 16505.patch added

possible patch to implement props argument in createSubclass, add inline doc and tests

comment:5 Changed 7 years ago by cjolif

If no comments, I'll proceed with that one and document this on the reference guide as well.

comment:6 Changed 6 years ago by cjolif

Resolution: fixed
Status: assignedclosed

In [30427]:

fixes #16505. Document, test, and add mixin parameter to declare.createSubclass. !strict.

comment:7 Changed 6 years ago by Colin Snover

In [30735]:

Fix invalid dojodoc for createSubclass. Refs #16505. !strict due to existing invalid code.

Note: See TracTickets for help on using tickets.