Re: Support getElementById and other methods of ShadowRoot on DocumentFragment

On Fri, Jun 29, 2012 at 8:03 PM, Elliott Sprehn <esprehn@gmail.com> wrote:
> DocumentFragment has querySelector and friends, but doesn't have
> getElementById or getElementByClass etc. Because of this the methods were
> explicitly added to ShadowRoot which seems kind of silly. There's also
> innerHTML on ShadowRoot but not on DocumentFragment.
>
> https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#shadow-root-object
>
> Could we get these methods added to DocumentFragment instead?
>
>  HTMLElement getElementById(in DOMString elementId);
>  NodeList getElementsByClassName(in DOMString tagName);
>  NodeList getElementsByTagName(in DOMString className);
>  NodeList getElementsByTagNameNS(DOMString namespace, DOMString localName);
>  attribute DOMString innerHTML;

This seems like yet another reason to make the root of the shadow tree
be an element rather than a DocumentFragment. In the component model
spec we're likely going to be creating shadow trees by cloning
<template> elements, so it seems to make a lot of sense to me to use
that cloned <template> element as the shadow tree, rather than
conceptually moving all the children over to this, arguably somewhat
awkward, DocumentFragment subclass.

/ Jonas

Received on Saturday, 30 June 2012 01:18:18 UTC