Differences between Components, Controls, and Behaviors
Posted by Tihomir Ivanov on 21 October 2008 04:17
Rating: 0.00
Behaviors, controls, and components are mostly the same. This is the
case because when compared to the amount of functionality the base component
type provides, behaviors and controls don’t provide much, and the
functionality they do provide doesn’t take them in a radically different
direction.
The one striking difference that does exist between a base component
and a behavior or control is behaviors and controls have a built-in association
to a DOM element because they are intended to be visual. In comparison,
components do not have a built-in association to a DOM element
because they are intended to be nonvisual.
Between behaviors and controls, the major difference is that a DOM element
can have only one control associated to it, whereas it can have multiple
associated behaviors.
| Object Type |
Can Be Associated to a DOM Element |
A DOM Element Can Have More Than One Associated to It |
Access to Object from DOM Element |
| Component |
Not allowed |
N/A (not directly assoassociated
to a DOM element). |
N/A (not directly assoassociated to a DOM element). |
| Control |
Must be acassociated
to a DOM element |
No, a DOM element can have only one associated control. |
Yes, a control can be acassociated cessed through a control expando property attached
to the DOM element. |
| Behavior |
Must be associated to a DOM element |
Yes, a DOM element can have one or more associated behaviors. |
Yes, a behavior can be accessed through an expando property of the behavior’s name from the
DOM element if the
behavior was named at the
time it was initialized.
All behaviors attached to
an element can be accessed
by a private _behaviors
array attached to the DOM
element. |
These rules are enforced during the creation of a component, behavior,
and control and dictate what base type your new type will inherit from.
Comments:
No comments yet.