Opened 15 years ago

Closed 14 years ago

#3703 closed enhancement (fixed)

dojo.declare should throw an error for null/undefine in mixin array

Reported by: guest Owned by: sjmiles
Priority: high Milestone: 0.9
Component: Core Version: 0.9
Keywords: Cc:
Blocked By: Blocking:


Say I have a Widget that needs mixin from dijit._Container. But I forgot to dojo.require that file. dojo.declare will still work as dijit._Container would be undefined.

If dojo.declare would throw an error, it would be much easier to catch the mistake.

example: dojo.declare("widget.Widget", [dijit._Widget, dijit._Templated, dijit._Container],

Change History (4)

comment:1 Changed 15 years ago by bill

Milestone: 0.9
Owner: changed from anonymous to sjmiles

Normally I'm against extra checks in the code but in this case it seems like it would save people a lot of time. Scott?

comment:2 Changed 15 years ago by dante

i'm with bill on this:

if it's a matter of making sure you dojo.require() anything you require, extra code to double check you should have required something is excessive. the ambiguity of mixins causes that. iirc, _something_ throws an error as soon as you try to use something you've forgotten to require ...

granted it a PITA to not know why something isn't working, but oversight code is 'bloat' ... eg: if you are mixing in _Container, you are probably calling getChildren(), and an error is throw.

comment:3 Changed 15 years ago by guest

Well, in a statically typed language, a missing include and then subsequent reference to that would yield a compile time error. Also, mixin of null or undefined seem like an error condition to me that shouldn't be ignored.

comment:4 Changed 14 years ago by sjmiles

Resolution: fixed
Status: newclosed

I would like this a lot better if it worked for superclasses too, but in any case, I added an exception for a null mixin in [10026].

Note: See TracTickets for help on using tickets.