A user account is required in order to edit this wiki, but we've had to disable public user registrations due to spam.
To request an account, ask an autoconfirmed user on Chat (such as one of these permanent autoconfirmed members).
Behavior Attachment
Jump to navigation
Jump to search
WORK IN PROGRESS
- element is DOM element.
- content is DOM content.
- document is HTML document
Decorator | Element | |
---|---|---|
Purpose | Give existing content new behavior and/or appearance. | Create new content building blocks. |
Paradigm | Aspect-Oriented Programming | Object-Oriented Programming |
Compartmentalization and Reuse Vehicle | Aspect | Inheritance |
Examples of Use |
|
|
Identity | Does not change the identity of the element. | Creates a new type of element. |
Lifetime | Transient, added and removed dynamically. | Permanent, originates with the element’s creation and exists through the lifetime. |
Environment | Foreign document or limited control of content. | Full control of content. |
Defining Traits |
|
|
Shadow Tree | Each decorator must have its own shadow subtree, and the aggregate shadow tree of an element is composed out of these subtrees. | Only one tree, initialized as the element is created. Inherited shadow trees can be reused, nested in the element's tree. |
DOM API | Should avoid adding any extra methods or properties to the DOM element that’s being decorated. | Explicitly interested in exposing methods or properties on the DOM element as its API. |
What does XBL2 do?
- There are two ways to bind: using binding element (inline or via external document) and using CSS. The former somewhat matches the notion to be element behavior, and the latter is the decorator behavior. However, there is no distinct difference in the attachment mechanism.
- Inheritance is entirely self-contained, using “extends” attribute. However, the prototype chain of the implementation object is fixed up to match inheritance
- There is a fair bit of machinery specified to marry the aspect and inheritance concepts seamlessly.
What does XBL1 do?
- There does not seem to be a separation between these two decorator and element behavior attachment. The http://mxr.mozilla.org/mozilla2.0/source/toolkit/content/xul.css seems to indicated the need for element attachment.
What does HTC do?
- HTC does not have the concept of shadow DOM, but the specified behavior is firmly an element behavior attachment.
What does sXBL do?
- It appears that the spec is abandoned, but the gist is similar to XBL2, except there is only one shadow tree, direct access to shadow subtree, and a binding model that seems to indicate element behavior attachment, but using decorator API.