<?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>21067</bug_id>
          
          <creation_ts>2013-02-21 02:38:00 +0000</creation_ts>
          <short_desc>[Shadow]: Provide an api to insertionParent</short_desc>
          <delta_ts>2013-08-07 08:51:16 +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="Steve Orvell">sorvell</reporter>
          <assigned_to name="Dimitri Glazkov">dglazkov</assigned_to>
          <cc>bugs</cc>
    
    <cc>dominicc</cc>
    
    <cc>erik.arvidsson</cc>
    
    <cc>esprehn</cc>
    
    <cc>hayato</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>83468</commentid>
    <comment_count>0</comment_count>
    <who name="Steve Orvell">sorvell</who>
    <bug_when>2013-02-21 02:38:00 +0000</bug_when>
    <thetext>Now that the shadowRoot element is exposed on a host element and insertion points have getDistributedNodes, it&apos;s possible to walk *down* the composed dom tree.

However, it&apos;s not possible to walk *up* the composed dom tree.

Since walking both directions is possible in normal dom, it should probably also be when using shadowDOM. This api is also one way to address this bug: https://www.w3.org/Bugs/Public/show_bug.cgi?id=21066.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84654</commentid>
    <comment_count>1</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-03-19 19:13:09 +0000</bug_when>
    <thetext>Should it just be distributedParent? There must be better names.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84658</commentid>
    <comment_count>2</comment_count>
    <who name="Elliott Sprehn">esprehn</who>
    <bug_when>2013-03-19 22:18:40 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; Should it just be distributedParent? There must be better names.

I dunno, if the method on &lt;shadow&gt; is getDistributedNodes() then distributedParent seems correct unless we want to rename that method too.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84659</commentid>
    <comment_count>3</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2013-03-19 22:20:43 +0000</bug_when>
    <thetext>insertionParent? That is what XBL1 uses (internally).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84661</commentid>
    <comment_count>4</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-03-19 22:23:20 +0000</bug_when>
    <thetext>(In reply to comment #3)
&gt; insertionParent? That is what XBL1 uses (internally).

+1.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84764</commentid>
    <comment_count>5</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2013-03-21 08:24:38 +0000</bug_when>
    <thetext>I think We should add the API to only Element and Text, rather than Node itself.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84813</commentid>
    <comment_count>6</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2013-03-22 00:43:34 +0000</bug_when>
    <thetext>Should it be available on ShadowRoot too?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84816</commentid>
    <comment_count>7</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2013-03-22 02:22:55 +0000</bug_when>
    <thetext>I&apos;d like to defer adding the API to ShadowRoot until we have a use case for that.

(In reply to comment #6)
&gt; Should it be available on ShadowRoot too?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84817</commentid>
    <comment_count>8</comment_count>
    <who name="Elliott Sprehn">esprehn</who>
    <bug_when>2013-03-22 02:29:23 +0000</bug_when>
    <thetext>(In reply to comment #7)
&gt; I&apos;d like to defer adding the API to ShadowRoot until we have a use case for
&gt; that.
&gt; 
&gt; (In reply to comment #6)
&gt; &gt; Should it be available on ShadowRoot too?

There is one though. If I&apos;m walking up the tree and I run into shadow I need to know if I&apos;ve been reprojected with a &lt;shadow&gt; to continue traversing upwards.

ShadowRoot should probably have both &quot;host&quot; and &quot;insertionParent&quot; (or whatever we&apos;re calling it).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84818</commentid>
    <comment_count>9</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2013-03-22 02:36:16 +0000</bug_when>
    <thetext>Thank you for the use case.
Okay. Let me add the API to the ShadowRoot too.

(In reply to comment #8)
&gt; (In reply to comment #7)
&gt; &gt; I&apos;d like to defer adding the API to ShadowRoot until we have a use case for
&gt; &gt; that.
&gt; &gt; 
&gt; &gt; (In reply to comment #6)
&gt; &gt; &gt; Should it be available on ShadowRoot too?
&gt; 
&gt; There is one though. If I&apos;m walking up the tree and I run into shadow I need
&gt; to know if I&apos;ve been reprojected with a &lt;shadow&gt; to continue traversing
&gt; upwards.
&gt; 
&gt; ShadowRoot should probably have both &quot;host&quot; and &quot;insertionParent&quot; (or
&gt; whatever we&apos;re calling it).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84822</commentid>
    <comment_count>10</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2013-03-22 06:30:28 +0000</bug_when>
    <thetext>As for ShadowRoot.insertionParent, let me raise an question.

Suppose a shadow host has two multiple shadow roots as follows:

  [older_shadowroot]
    - &lt;div id=div1&gt;

  [younger_shadowroot]
    - &lt;shadow id=shadow1&gt;


1. What should be &apos;div1.insertionParent&apos;?

   I am sure that should be &apos;div1.insertionParent == shadow1&apos;, right?
   It&apos;s consistent with &lt;content&gt; element case.

2. What should be older_shadowroot.insertionParent?

   I am wondering that should be &apos;older_shadowroot.insertionParent == shadow1&apos; or not.


I feel some strangeness for &apos;div1.insertionParent == older_shadowroot.insertionParent == shadow1&apos;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84823</commentid>
    <comment_count>11</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2013-03-22 06:50:00 +0000</bug_when>
    <thetext>Note that we can not traverse every nodes on eventPath by using only insertionParent.

That means we cannot emulate event.path by insertionParent.

The reason is the reprojection. We can not traverse all intermediate insertion points, through which the node is reprojected. Since insertionParent is stateless.

To emulate event.path, we need an additional parameter, the original event target node, like:

element.parentOnEventPath(eventTarget)


(In reply to comment #10)
&gt; As for ShadowRoot.insertionParent, let me raise an question.
&gt; 
&gt; Suppose a shadow host has two multiple shadow roots as follows:
&gt; 
&gt;   [older_shadowroot]
&gt;     - &lt;div id=div1&gt;
&gt; 
&gt;   [younger_shadowroot]
&gt;     - &lt;shadow id=shadow1&gt;
&gt; 
&gt; 
&gt; 1. What should be &apos;div1.insertionParent&apos;?
&gt; 
&gt;    I am sure that should be &apos;div1.insertionParent == shadow1&apos;, right?
&gt;    It&apos;s consistent with &lt;content&gt; element case.
&gt; 
&gt; 2. What should be older_shadowroot.insertionParent?
&gt; 
&gt;    I am wondering that should be &apos;older_shadowroot.insertionParent ==
&gt; shadow1&apos; or not.
&gt; 
&gt; 
&gt; I feel some strangeness for &apos;div1.insertionParent ==
&gt; older_shadowroot.insertionParent == shadow1&apos;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84825</commentid>
    <comment_count>12</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2013-03-22 08:21:35 +0000</bug_when>
    <thetext>For events XBL1 has .originalTarget but I really hope we don&apos;t add similar
thing for web components. As little as possible of the shadow DOM should be
exposed outside.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84826</commentid>
    <comment_count>13</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2013-03-22 08:28:13 +0000</bug_when>
    <thetext>Agreed. I&apos;d like to avoid adding API unless there is a strong use case for that.

(In reply to comment #12)
&gt; For events XBL1 has .originalTarget but I really hope we don&apos;t add similar
&gt; thing for web components. As little as possible of the shadow DOM should be
&gt; exposed outside.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87793</commentid>
    <comment_count>14</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2013-05-17 10:20:48 +0000</bug_when>
    <thetext>event.path() was landed in blink as described in
https://www.w3.org/Bugs/Public/show_bug.cgi?id=21066#c25.

Although we still have to spec event.path(), I&apos;d like to know whether we still need insertionParent or not because event.path() might be sufficient.


(In reply to comment #13)
&gt; Agreed. I&apos;d like to avoid adding API unless there is a strong use case for
&gt; that.
&gt; 
&gt; (In reply to comment #12)
&gt; &gt; For events XBL1 has .originalTarget but I really hope we don&apos;t add similar
&gt; &gt; thing for web components. As little as possible of the shadow DOM should be
&gt; &gt; exposed outside.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87806</commentid>
    <comment_count>15</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-05-17 16:37:58 +0000</bug_when>
    <thetext>(In reply to comment #14)
&gt; event.path() was landed in blink as described in
&gt; https://www.w3.org/Bugs/Public/show_bug.cgi?id=21066#c25.
&gt; 
&gt; Although we still have to spec event.path(), I&apos;d like to know whether we
&gt; still need insertionParent or not because event.path() might be sufficient.
&gt; 
&gt; 
&gt; (In reply to comment #13)
&gt; &gt; Agreed. I&apos;d like to avoid adding API unless there is a strong use case for
&gt; &gt; that.
&gt; &gt; 
&gt; &gt; (In reply to comment #12)
&gt; &gt; &gt; For events XBL1 has .originalTarget but I really hope we don&apos;t add similar
&gt; &gt; &gt; thing for web components. As little as possible of the shadow DOM should be
&gt; &gt; &gt; exposed outside.

Okay. I will wait to add insertionParent to the spec until webdevs (Polymer teams and others) have concluded that event.path is not enough.

If that happens, I think we need to go back to re-evaluate the opportunities for a better solution (and maybe even nix event.path in the process).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87809</commentid>
    <comment_count>16</comment_count>
    <who name="Elliott Sprehn">esprehn</who>
    <bug_when>2013-05-17 17:15:15 +0000</bug_when>
    <thetext>(In reply to comment #15)
&gt; ...
&gt; 
&gt; Okay. I will wait to add insertionParent to the spec until webdevs (Polymer
&gt; teams and others) have concluded that event.path is not enough.
&gt; 
&gt; If that happens, I think we need to go back to re-evaluate the opportunities
&gt; for a better solution (and maybe even nix event.path in the process).

As a webdev, event path is not enough. It doesn&apos;t address Google Feedback&apos;s use case of wanting to walk up the ancestor chain to figure out containing blocks, event.path would require dispatching fake events on every node and is crazy expensive (and does rewriting and other magic).

It also doesn&apos;t allow positioning an object easily, since you have no trivial way to walk up the tree and decide who your positioned ancestor is without dispatching fake events...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87814</commentid>
    <comment_count>17</comment_count>
    <who name="Steve Orvell">sorvell</who>
    <bug_when>2013-05-17 17:29:32 +0000</bug_when>
    <thetext>event.path solves the use cases outlined in the bug where it was requested: https://www.w3.org/Bugs/Public/show_bug.cgi?id=21066. In that thread, it was noted that insertionParent does not provide enough information to construct the event.path.

If there is a general need to be able to construct the composed ancestor tree by traversing up from a given node, insertionParent is insufficient for that purpose for the same reason. See, for example, https://www.w3.org/Bugs/Public/show_bug.cgi?id=21066#c16.

It seems to me that reprojection makes insertionParent not a useful concept and we should remove it and address general &apos;traversing up the composed tree&apos; via some alternate api, if necessary.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87863</commentid>
    <comment_count>18</comment_count>
    <who name="Steve Orvell">sorvell</who>
    <bug_when>2013-05-18 01:27:39 +0000</bug_when>
    <thetext>So, we can remove event path from the list of reasons we need an api to &apos;for a given node, find its ancestors in the composed tree&apos;.

However, as Elliot points out, there are other reasons we need this information (see above). He also separately mentioned the need to discover if a node visible in an overflow scrolling block.

One option is that we could address each of these use cases independently and add api to address them, as we&apos;ve done with event.path(). That seems impractical and that leaves us with needing the general api.

As previously mentioned, reprojection makes insertionParent insufficient for constructing the list we want; however, we probably do not need actual insertion points in the list of ancestors. Instead we can live with &apos;ancestors in the composed *render* tree&apos;.

Given this, we can replace insertionParent with renderParent or composedParent and this would point to the parent of the last insertion point to which a node is distributed. This should be enough to generate the necessary list.

If we decide we do need insertion points in the list of ancestors, we could change insertionParent to insertionPath and this would be a list of insertion points to which the node is distributed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87900</commentid>
    <comment_count>19</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2013-05-20 07:10:25 +0000</bug_when>
    <thetext>Thank you the comments. Let me summarise the discussion so far:

- We need event.path() to address the use case described in https://www.w3.org/Bugs/Public/show_bug.cgi?id=21066

- We don&apos;t need insertionParent, which doesn&apos;t meet any requirement of any use cases. We can remove insertionParent.

- We still need another API to address the use case, &apos;Traversing up the composed tree&apos;. The API&apos;s name might be either &apos;renderParent&apos; or &apos;composedParent&apos;. We might need a list of insertionPoints which are skipped.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88050</commentid>
    <comment_count>20</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2013-05-22 05:46:16 +0000</bug_when>
    <thetext>If there is no objection to remove insertionoParent in a few days, let me remove the experimental support from blink. I am assuming no one is currently using that.

I&apos;d like to provide an alternative which meets a requirement.
That should be renderParent (or composedParent?), which skips insertion points.

I am not sure whether renderParent is good name or not. Any suggestions?


(In reply to comment #19)
&gt; Thank you the comments. Let me summarise the discussion so far:
&gt; 
&gt; - We need event.path() to address the use case described in
&gt; https://www.w3.org/Bugs/Public/show_bug.cgi?id=21066
&gt; 
&gt; - We don&apos;t need insertionParent, which doesn&apos;t meet any requirement of any
&gt; use cases. We can remove insertionParent.
&gt; 
&gt; - We still need another API to address the use case, &apos;Traversing up the
&gt; composed tree&apos;. The API&apos;s name might be either &apos;renderParent&apos; or
&gt; &apos;composedParent&apos;. We might need a list of insertionPoints which are skipped.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88077</commentid>
    <comment_count>21</comment_count>
    <who name="Steve Orvell">sorvell</who>
    <bug_when>2013-05-22 17:18:11 +0000</bug_when>
    <thetext>I prefer composedParent over renderParent; however, I am wondering about the alternative of simply changing insertionParent to insertionPath. In this case, insertionPath would be the list of insertion points to which a node was distributed. Given this, I believe the full event.path could be constructed. Hayato-san, I respect your knowledge of this topic, do you agree about this?

While the event path tree is not necessary for the use cases in this thread, I&apos;m not sure it&apos;s never necessary, and it seems odd to have event.path and traversal via &apos;composedParent&apos; produce a different tree. I&apos;d rather err on the side of providing more information.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88114</commentid>
    <comment_count>22</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2013-05-23 04:49:04 +0000</bug_when>
    <thetext>(In reply to comment #21)
&gt; I prefer composedParent over renderParent; however, I am wondering about the
&gt; alternative of simply changing insertionParent to insertionPath. In this
&gt; case, insertionPath would be the list of insertion points to which a node
&gt; was distributed. Given this, I believe the full event.path could be
&gt; constructed. Hayato-san, I respect your knowledge of this topic, do you
&gt; agree about this?

Agreed. If we can return the list of insertion points, we can construct full event.path in theory.

At the same time, I&apos;m afraid that might require some amount of code in the consumer side.
Let me emulate eventPath using insertionPath():

This is a pseudo code.

function eventPath(node) {
  if (!node)
     return [];
  var insertionPoints = node.insertionPath();
  if (insertionPoints.isEmpty) {
    if (node.isShadowRoot)
      if (node.toShadowRoot.isYoungestShadowRoot)
        return [node] ++ eventPath(node.shadowHost);
      else
        return [node];
    else
      return [node] ++ eventPath(node.parentNode));
  else {
    return [node] ++ insertionPoints ++ eventPath(insertionPoints.last.parentNode);
  }
}

... and I am now feeling there might be a bug in this eventPath function. I&apos;m not sure. :)
The point is that it might not be easy to emulate eventPath in the client side.


&gt; 
&gt; While the event path tree is not necessary for the use cases in this thread,
&gt; I&apos;m not sure it&apos;s never necessary, and it seems odd to have event.path and
&gt; traversal via &apos;composedParent&apos; produce a different tree. I&apos;d rather err on
&gt; the side of providing more information.

Thank you for the info. I appreciate that. Let&apos;s continue discussion and iterate cycle until we have a good spec.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88252</commentid>
    <comment_count>23</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2013-05-27 11:24:54 +0000</bug_when>
    <thetext>I think we need further discussion to define a good alternative APIs.

At least, looks like no one needs the current implementation of insertionParent. Let me remove it from the blink.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91058</commentid>
    <comment_count>24</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2013-07-22 04:57:09 +0000</bug_when>
    <thetext>FYI. webkitInsertionParent has been removed.

https://chromiumcodereview.appspot.com/15757013</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91442</commentid>
    <comment_count>25</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2013-07-31 02:03:27 +0000</bug_when>
    <thetext>Let me try to spec the insertionPath and implement it in blink to get more feedbacks.
See the discussion in http://code.google.com/p/chromium/issues/detail?id=234031.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91716</commentid>
    <comment_count>26</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2013-08-07 05:50:59 +0000</bug_when>
    <thetext>I feel that API should be named, &apos;getDestinationInsertionPoints()&apos; because:

- The spec is using the terms of *distributed nodes* and *destination insertion points*.

  - https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#dfn-distributed-nodes
  - https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#dfn-destination-insertion-points

- We already have the API, getDistributedNodes().


I also feel that if the destination insertion points has an insertion point whose root node is a user-agent shadow root, we should discard the entire list and return an empty NodeList instead.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91717</commentid>
    <comment_count>27</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2013-08-07 08:51:16 +0000</bug_when>
    <thetext>I&apos;ve updated the spec.
https://dvcs.w3.org/hg/webcomponents/rev/77db857bafaa

Let me close this issue.
If you have any concerns, feel free to re-open this issue and add a comment.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>