layout | title |
---|---|
doc |
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">
. - Widgets are parsed automatically without needing a
parseOnLoad:true
flag. But there's no 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. - In dijit you could alter when the "change" event fired by setting the
intermediateChanges
flag to true or false. In delite, there are two separate events: "input" and "change". Listen to the "input" event to get notifications as the user is changing the value (for example, as the user is dragging the slider), and listen to the "change" event to get a notification when the user has finished changing the value (for example, mouseup on a slider). Also note that the "change" and "input" events only fire when the user changes the value, not when the value is changed programatically.
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.effectiveDir === "ltr"){
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:
postRender: 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
;
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 toconstructor()
postscript()
no longer runs;preCreate()
was renamed topreRender()
.- The
buildRendering()
method has been renamed torender()
. It 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. However, usually widgets will not redefinerender()
at all, but rather just define thetemplate
property. - There's no
postMixInProperties()
method any more. There is one calledpreRender()
that runs before rendering. postCreate()
renamed topostRender()
- The widget initialization parameters are not applied until after
render()
andpostRender()
complete. - Custom setters still exist, but often its preferable to recompute 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 requirejs-dplugins/css! to load its own CSS.
Further, delite/CssState (previously called dijit/_CssStateMixin) no longer sets CSS classes for hover, focus or active,
so the widget CSS should just use the :focus
, :hover
, and :active
pseudo-classes.
HasDropDown now forwards keystrokes to popups by emitting the "keydown" event on the popup rather than calling
a handleKey()
method.
Dropdowns should indicate they have executed/canceled by calling this.emit("execute")
, this.emit("change")
,
or this.emit("cancel")
, rather than calling onExecute()
, onChange()
, or onCancel()
.
Dropdowns don't automatically get overflow: auto
CSS but they should take some measure,
perhaps by extending delite/Scrollable
, to display a scrollbar when their size
is reduced.
_KeyNavMixin has been renamed to KeyNav.
The _keyNavCodes
property has been removed as KeyNav now figures out the method name to call automatically.
However, the method names for arrows have been changed:
- onLeftArrow --> previousKeyHandler
- onRightArrow --> nextKeyHandler
- onDownArrow --> downKeyHandler
- onUpArrow --> upKeyHandler
Methods for handling other keys (like SPACE or ENTER) are similarly named, ex: spaceKeyHandler() and enterKeyHandler().
delite/activationTracker (previously called dijit/focus) no longer calls onFocus()
and onBlur()
(or _onFocus()
and _onBlur()
) methods on a widget. Rather, it emits delite-activated
and
delite-deactivated
events on the widget.
Note that most widgets should probably just call this.on("focusin", ...)
and this.on("focusout", ...)
rather than depending on delite/activationTracker. It's mainly for popups.