7.4.06 # Web Component Model

After reading the article about ALE - Ajax Linking & Embedding over at Ajaxian I was thinking a while about the potential of this concept. I wasn't so much drawing the parallel to OLE, but stepped down a level to the concept of Microsoft's COM-Programming.

Basically COM-Interfaces allow design by contract via immutable interfaces and demand separation of interface and implementation. Given this, COM-components implementing identical interfaces are arbitrarily interchangeable.

Considering an inline web component, we might start with a clearly defined document fragment. A very good example for that is the open standard microformat XOXO, which is

A simple, open outline format written in standard XHTML and suitable for embedding in (X)HTML, Atom, RSS, and arbitrary XML.

Given a specific XOXO structure, we could easily define two different presentations via CSS, which might be even switched by the user.

But what's about behaviour. XOXO components might be

So if there would be a standardized object interface – perhaps defined alongside with the microformats specification, we rather did a big step forward to a truely reusable, implementation independent inline web component. The interface definition of a collapsable XOXO element might look somewhat like:

interface XOXOCollapsableElement: Element {
void collapseItem(bool collapse);
void forEachItem(Function callback);
NodeList filterItems(Function callback);

There might be another interface for an editable XOXO element.

interface XOXoEditableElement: Element {

Now as a user i could download a specific XOXO object implementation, which implements either both interfaces or merely the XOXOCollapsableElement interface.

I believe, the long term benefit is worth the effort of agreeing to common interfaces for heavily reused inline web components.