<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>15611</bug_id>
          
          <creation_ts>2012-01-18 17:35:27 +0000</creation_ts>
          <short_desc>[Shadow]: Consider element.createShadowRoot as API for creating ShadowRoot objects.</short_desc>
          <delta_ts>2012-11-27 19:11:38 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>HISTORICAL - Component Model</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>18428</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Elliott Sprehn">esprehn</reporter>
          <assigned_to name="Dimitri Glazkov">dglazkov</assigned_to>
          <cc>dglazkov</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>62864</commentid>
    <comment_count>0</comment_count>
    <who name="Elliott Sprehn">esprehn</who>
    <bug_when>2012-01-18 17:35:27 +0000</bug_when>
    <thetext>Read only access to every ShadowRoot must be provided for each element to support tools. Without it something like Readability wouldn&apos;t be possible because there&apos;s no way to access the content of the page that&apos;s inside the shadow DOM.

This also makes tools like Google Feedback impossible to build because there&apos;s no way to access the nodes  in the shadow DOM for rendering in screenshots. Without the addition of CanvasRenderingContext2D #renderElement() this cripples HTML screenshot tools.

In general the API appears to be backwards because the ShadowRoot constructor is invoked directly instead of being created through a factory method like createElement().

root = element.createShadowRoot() =&gt; new root.
element.shadowRoots =&gt; list of roots.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62866</commentid>
    <comment_count>1</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2012-01-18 18:26:43 +0000</bug_when>
    <thetext>Thanks for the feedback! There are two issues reported here:

(In reply to comment #0)
&gt; Read only access to every ShadowRoot must be provided for each element to
&gt; support tools. Without it something like Readability wouldn&apos;t be possible
&gt; because there&apos;s no way to access the content of the page that&apos;s inside the
&gt; shadow DOM.
&gt; 
&gt; This also makes tools like Google Feedback impossible to build because there&apos;s
&gt; no way to access the nodes  in the shadow DOM for rendering in screenshots.
&gt; Without the addition of CanvasRenderingContext2D #renderElement() this cripples
&gt; HTML screenshot tools.

This is bug 15409.

&gt; 
&gt; In general the API appears to be backwards because the ShadowRoot constructor
&gt; is invoked directly instead of being created through a factory method like
&gt; createElement().
&gt; 
&gt; root = element.createShadowRoot() =&gt; new root.
&gt; element.shadowRoots =&gt; list of roots.

This is new. I&apos;ll repurpose the bug to track this. So far, my thinking is that &quot;new ShadowRoot(..)&quot; is shorter, and doesn&apos;t require extending HTMLElement API surface.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>77772</commentid>
    <comment_count>2</comment_count>
    <who name="Elliott Sprehn">esprehn</who>
    <bug_when>2012-11-02 20:42:12 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; ...
&gt; This is new. I&apos;ll repurpose the bug to track this. So far, my thinking is
&gt; that &quot;new ShadowRoot(..)&quot; is shorter, and doesn&apos;t require extending
&gt; HTMLElement API surface.

We&apos;re already extending the API surface with public shadows, and having a constructor that has side effects is very weird. I can&apos;t think of any other place in the platform where constructing an object has side effects like this (and it&apos;s usually considered a code smell).

It&apos;s particularly weird in the implementation of WebKit as we call ShadowRoot::create(this) often and discard the return value which is non-obvious to someone looking at the code. Once we expose public shadows people may do the same thing:

function doSomething() {
  // Not obvious this does anything.
  new ShadowRoot(element);
}

element.oldestShadowRoot.appendChild(...);

so I&apos;d propose addShadowRoot() which is the same number of characters and models what&apos;s going on better.

element.addShadowRoot()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78494</commentid>
    <comment_count>3</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2012-11-20 00:05:32 +0000</bug_when>
    <thetext>http://dvcs.w3.org/hg/webcomponents/rev/e0dfe2ac8104</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78941</commentid>
    <comment_count>4</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2012-11-27 19:11:38 +0000</bug_when>
    <thetext>*** Bug 17447 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>