#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)
Change History (8)
comment:1 Changed 10 years ago by
Owner: | set to cjolif |
---|---|
Status: | new → assigned |
comment:2 Changed 10 years ago by
Cc: | ben hockey added |
---|
comment:3 Changed 10 years ago by
comment:4 Changed 10 years ago by
Milestone: | tbd → 1.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 9 years ago by
Attachment: | 16505.patch added |
---|
possible patch to implement props argument in createSubclass, add inline doc and tests
comment:5 Changed 9 years ago by
If no comments, I'll proceed with that one and document this on the reference guide as well.
FYI, ticket submitted in response to http://thread.gmane.org/gmane.comp.web.dojo.devel/18414/focus=18440.