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: Difference between revisions

From WHATWG Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 5: Line 5:
* document is HTML document
* document is HTML document


{| cellpadding="10"
{| cellpadding="10" cellspacing="0" style="border-collapse: collapse;"
|+ Comparison between the decorator and element behavior attachment.
|+ Comparison between the decorator and element behavior attachment.
|- valign="top" style="border-bottom: 1px solid LightGray;"
! width="10%" |
! width="10%" |
! width="40%" align="left" | Decorator
! width="40%" align="left" | Decorator
! width="40%" align="left" | Element
! width="40%" align="left" | Element
|- valign="top"
|- valign="top" style="border-bottom: 1px solid LightGray;"
! align="right" | Purpose
! align="right" | Purpose
| Give existing content new behavior and/or appearance.  
| Give existing content new behavior and/or appearance.  
| Create new content building blocks.
| Create new content building blocks.
|- valign="top"
|- valign="top" style="border-bottom: 1px solid LightGray;"
! align="right" | Paradigm
! align="right" | Paradigm
| [http://en.wikipedia.org/wiki/Aspect-oriented_programming Aspect-Oriented Programming]
| [http://en.wikipedia.org/wiki/Aspect-oriented_programming Aspect-Oriented Programming]
| [http://en.wikipedia.org/wiki/Object-oriented_programming Object-Oriented Programming]
| [http://en.wikipedia.org/wiki/Object-oriented_programming Object-Oriented Programming]
|- valign="top"
|- valign="top" style="border-bottom: 1px solid LightGray;"
! align="right" | Use Cases
! align="right" | Use Cases
|
|
Line 27: Line 28:
* Define an element to represent a customizable calendar view.
* Define an element to represent a customizable calendar view.
* Define a button row control with application-specific grouping logic (see GMail button bars).
* Define a button row control with application-specific grouping logic (see GMail button bars).
|- valign="top"  
|- valign="top" style="border-bottom: 1px solid LightGray;"
! align="right" | Identity
! align="right" | Identity
| Does not change the identity of the element.
| Does not change the identity of the element.
| Creates a new type of element.
| Creates a new type of element.
|- valign="top"
|- valign="top" style="border-bottom: 1px solid LightGray;"
! align="right" | Lifetime  
! align="right" | Lifetime  
| Transient, added and removed dynamically.
| Transient, added and removed dynamically.
| Permanent, originates with the element’s creation and exists through the lifetime.
| Permanent, originates with the element’s creation and exists through the lifetime.
|- valign="top"
|- valign="top" style="border-bottom: 1px solid LightGray;"
! align="right" | Content Environment
! align="right" | Content Environment
| Foreign document or limited control of content.
| Foreign document or limited control of content.
| Full control of content.
| Full control of content.
|- valign="top"
|- valign="top" style="border-bottom: 1px solid LightGray;"
! align="right" | Defining Traits
! align="right" | Defining Traits
|
|
Line 47: Line 48:
* Composable
* Composable
* Interoperable
* Interoperable
|- valign="top"
|- valign="top" style="border-bottom: 1px solid LightGray;"
! align="right" | Shadow Tree
! align="right" | Shadow Tree
| Each decorator must have its own shadow subtree, and the aggregate shadow tree of an element is composed out of these subtrees.
| Each decorator must have its own shadow subtree, and the aggregate shadow tree of an element is composed out of these subtrees.

Revision as of 19:40, 4 July 2011

WORK IN PROGRESS

  • element is DOM element.
  • content is DOM content.
  • document is HTML document
Comparison between the decorator and element behavior attachment.
Decorator Element
Purpose Give existing content new behavior and/or appearance. Create new content building blocks.
Paradigm Aspect-Oriented Programming Object-Oriented Programming
Use Cases
  • Add special UI treatment to all vcards in a document.
  • Create an extension to provide extra download options for certain types of links.
  • Implement built-in HTML controls: input/textarea, media, etc.
  • Define an element to represent a customizable calendar view.
  • Define a button row control with application-specific grouping logic (see GMail button bars).
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.
Content Environment Foreign document or limited control of content. Full control of content.
Defining Traits
  • Unobtrusive
  • Dynamic
  • Composable
  • Interoperable
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.
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.