<?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>20260</bug_id>
          
          <creation_ts>2012-12-06 06:22:25 +0000</creation_ts>
          <short_desc>[Shadow]: ShadowRoot should have olderShadowRoot attribute to get older shadow tree.</short_desc>
          <delta_ts>2013-10-24 11:07:27 +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>22715</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Morrita Hajime">morrita</reporter>
          <assigned_to name="Hayato Ito">hayato</assigned_to>
          <cc>dominicc</cc>
    
    <cc>hayato</cc>
    
    <cc>sgrekhov</cc>
    
    <cc>sorvell</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>79527</commentid>
    <comment_count>0</comment_count>
    <who name="Morrita Hajime">morrita</who>
    <bug_when>2012-12-06 06:22:25 +0000</bug_when>
    <thetext>It could be named olderShadowRoot but |shadowRoot| aligns ShadowAware interface
and better for iterating over for() loop.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79581</commentid>
    <comment_count>1</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2012-12-06 21:21:59 +0000</bug_when>
    <thetext>I am not sure about this. We expose the composed shadow tree with .shadowRoot and .olderShadowRoot. This would expose the tree stack, and I don&apos;t know if that&apos;s good.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79598</commentid>
    <comment_count>2</comment_count>
    <who name="Morrita Hajime">morrita</who>
    <bug_when>2012-12-07 01:38:17 +0000</bug_when>
    <thetext>&gt; I am not sure about this. We expose the composed shadow tree with
&gt; .shadowRoot and .olderShadowRoot. This would expose the tree stack, and I
&gt; don&apos;t know if that&apos;s good.

Then we can hide older shadow root by putting younger one over it without any
&lt;shadow&gt; element. If we prefer encapsulation by default, this would be way to.
If we switch to all-visible-by-default principle, we should have this.
I&apos;m not sure which is better either.
If it is intentional not to have this, that&apos;s totally fine for me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>83853</commentid>
    <comment_count>3</comment_count>
    <who name="Steve Orvell">sorvell</who>
    <bug_when>2013-03-01 00:17:14 +0000</bug_when>
    <thetext>Currently olderShadowRoot is defined only as a property of a &lt;shadow&gt; element. 

Given a shadowRoot, to find olderShadowRoot, one must find the &lt;shadow&gt; element inside it and then interrogate that object for the olderShadowRoot. 

This is inconvenient and it would be simpler if olderShadowRoot were simply a property of a shadowRoot node.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>83887</commentid>
    <comment_count>4</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2013-03-01 21:51:15 +0000</bug_when>
    <thetext>*** Bug 21166 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>83888</commentid>
    <comment_count>5</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2013-03-01 21:53:50 +0000</bug_when>
    <thetext>Defining olderShadowRoot on HTMLShadowElement is inconvenient for code that wants to walk the list of ShadowRoots. It is necessary to write something like:

function forEachShadowRoot(host, f) {
  for (var s = host.shadowRoot; s; s = olderShadowRootOf(s)) {
    f(s);
  }
}

function olderShadowRootOf(s) {
  var shadowElements = s.querySelectorAll(&apos;shadow&apos;);
  for (var i = 0; i &lt; shadowElements.length; i++) {
    var shadowElement = shadowElements[i];
    if (shadowElement.olderShadowRoot) {
      return shadowElement.olderShadowRoot;
    }
  }
  // There were no shadow elements, or they were all inert
  shadowElement = document.createElement(&apos;shadow&apos;);
  s.appendChild(shadowElement);
  var result = shadowElement.olderShadowRoot;
  shadowElement.remove();
  return result;
}

This seems excessively complicated for this use case; it would be better if olderShadowRoot was defined on ShadowRoot, then one could simply write the loop in a straightforward way:

function forEachShadowRoot(host, f) {
  for (var s = host.shadowRoot; s; s = s.olderShadowRoot) {
    f(s);
  }
}

(In reply to comment #0)
&gt; It could be named olderShadowRoot but |shadowRoot| aligns ShadowAware
&gt; interface and better for iterating over for() loop.

I agree that this simplifies loops. However it could be confusing if in future ShadowRoot could have a ShadowRoot, or if ShadowRoot became an element. So I think the name olderShadowRoot is better.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89297</commentid>
    <comment_count>6</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2013-06-14 05:39:28 +0000</bug_when>
    <thetext>Since anyone who could have an objection has had a reeeeeeeasonable time to respond, I am implementing this in Blink now (behind a flag.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90880</commentid>
    <comment_count>7</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-07-17 20:22:53 +0000</bug_when>
    <thetext>*** Bug 20355 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95294</commentid>
    <comment_count>8</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2013-10-24 11:07:27 +0000</bug_when>
    <thetext>The spec was updated: https://dvcs.w3.org/hg/webcomponents/rev/867a6026f003</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>