layout | title |
---|---|
default |
delite/migration |
- In markup, widgets look like
<d-star-rating foo=bar>
rather than<div data-dojo-type=delite/StarRating data-dojo-props="foo: bar">
. For widgets that enhance an existing tag, syntax is<button is="d-button">
. - Use
register.parse()
rather thandojo/parser.parse()
. There's noparseOnLoad:true
or auto-loading ordata-dojo-mixins
. - Since each widget defines and loads its own CSS, you don't need to manually include dijit.css or claro.css;
also, the theme is determined automatically so you don't need to add
class="claro"
to the<body>
node.
dojo.declare() is replaced by dcl(). Its usage is similar except for super calls.
Rather than using this.inherited()
, you use dcl.superCall(). So instead of:
_inZeroSettingArea: function(/*Number*/ x, /*Number*/ domNodeWidth){
if(this.isLeftToRight()){
return this.inherited(arguments);
}else{
return x > (domNodeWidth - this.zeroAreaWidth);
}
}
You would do:
_inZeroSettingArea: dcl.superCall(function(sup){
return function(/*Number*/ x, /*Number*/ domNodeWidth){
if(this.isLeftToRight()){
return sup.call(this, x, domNodeWidth);
}else{
return x > (domNodeWidth - this.zeroAreaWidth);
}
};
})
Often though it's simpler than this. Many widget methods are automatically chained. So a V1 postCreate()
method like:
postCreate: function(){
this.inherited(arguments);
... do stuff ...
}
can (and should) be replaced by:
postCreate: function(){
... do stuff ...
}
Note also that dcl does have an this.inherited() type feature. However, it's not recommended because:
this.inherited()
will run slower thandcl.superCall()
because it resolves at runtime rather than declare time- it's easier to step through super calls in the debugger when using
dcl.superCall()
.
Widgets are declared via register()
rather than dojo.declare()
, and must extend HTMLElement
or a subclass;
see the documentation for register() for details
this
points to the widget's root node.
this.srcNodeRef
and this.domNode
both replaced by this
; for example this.className = "myButton"
create()
renamed tocreatedCallback()
constructor()
andpostscript()
no longer run; move custom code from constructor topreCreate()
.- The
buildRendering()
method must not try to create the root DOMNode. It already exists. It should just set attributes on the root node, and create sub nodes and/or text inside the root node. - There's no
postMixInProperties()
method any more. There is one calledpreCreate()
that runs before rendering. - The widget initialization parameters are not applied until after
buildRendering()
andpostCreate()
complete. - Custom setters still exist, but often its preferable to recomput property values in
computeProperties()
and to redraw the widget inrefreshRendering()
. Both these methods are called asynchronously after a batch of property changes.
_TemplatedMixin
is replaced by the handlebars! plugin, see that page for details.
Resources are loaded through i18n!
plugin rather than a loadResource()
type method.
A widget should use delite/theme! or delite/css! to load its own CSS.