Re: Component Model: Landing Experimental Shadow DOM API in WebKit

Anne van Kesteren:
> > How can Document inherit from TreeScope if it already inherits from Node?

Dimitri Glazkov:
> TreeScope is a Node.

That doesn’t work now that Web IDL allows only single inheritance.

Here is how I would write the IDL, if I understand what you want
correctly:

  // augment Element with these two attributes
  partial interface Element {
    attribute ShadowRoot shadow setraises(DOMException);
    attribute String pseudo;
  };

  // a mixin
  [NoInterfaceObject]
  interface TreeScope {
    readonly TreeScope parentTreeScope;
    Element getElementById(in DOMString elementId);
  };

  // ShadowRoot is a new type of Node
  interface ShadowRoot : Node {
    attribute bool applyAuthorSheets;
    readonly attribute Element shadowHost;
  };
  // which has TreeScope functionality
  ShadowRoot implements TreeScope;

  // augment Document with createShadow()
  partial interface Document {
    ShadowRoot createShadow();
  };

  // Documents also have TreeScope functioanlity
  Document implements TreeScope;

-- 
Cameron McCormack ≝ http://mcc.id.au/

Received on Wednesday, 29 June 2011 22:29:41 UTC