anonymous classes, generated IDs

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

anonymous classes, generated IDs

Gerhard Presser-2
hi all,
I noticed, that if you use declare() to create new widget prototypes,
instances of this widget (without explicit ID) will have an ID like
uniqueName_XXX.
This is due to the declaredClass-property not being set.
All default dijit widgets have this property properly set, because they
use declare("dijit.form.xxx",[...],{....});

Isn't this the deprecated way of declaring modules? Does this polute the
global namespace?

BUT - for debugging reasons it would be nice to have a more meaningful
default-IDs.
I don't want to manually manage the names.
Would it be a good idea to write

define([....,"module"),function(...declare,module){return
declare(module.id,{..});});

or something like that.
could this somehow become the default-behavior?
regards

--
Gerhard Presser

Groiss Informatics GmbH
Strutzmannstra├če 10
A-9020 Klagenfurt
AUSTRIA

Work: +43 463 504694-17
Fax: +43 463 504694-10
Web: www.groiss.com

FN 168125v LG Klagenfurt | UID ATU44898401

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: anonymous classes, generated IDs

Kenneth G. Franqueiro
It should still be possible to get that behavior, minus the global
namespace pollution, by specifying declaredClass in your prototype.

I wouldn't think it's feasible to make module.id built-in default
behavior, since making it the default behavior would mean putting it in
dojo/_base/declare...  but then module.id is always going to be
'dojo/_base/declare'.

(And yes, dijit still pollutes the global namespace, to avoid breaking
old apps during Dojo upgrades.)

--Ken

On 3/24/2016 3:57 PM, Gerhard Presser wrote:

> hi all,
> I noticed, that if you use declare() to create new widget prototypes,
> instances of this widget (without explicit ID) will have an ID like
> uniqueName_XXX.
> This is due to the declaredClass-property not being set.
> All default dijit widgets have this property properly set, because they
> use declare("dijit.form.xxx",[...],{....});
>
> Isn't this the deprecated way of declaring modules? Does this polute the
> global namespace?
>
> BUT - for debugging reasons it would be nice to have a more meaningful
> default-IDs.
> I don't want to manually manage the names.
> Would it be a good idea to write
>
> define([....,"module"),function(...declare,module){return
> declare(module.id,{..});});
>
> or something like that.
> could this somehow become the default-behavior?
> regards
>
--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest