This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 17023 - [Shadow]: Clarify how insertion points behave when they are shadow hosts
Summary: [Shadow]: Clarify how insertion points behave when they are shadow hosts
Status: RESOLVED INVALID
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: HISTORICAL - Component Model (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Dimitri Glazkov
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 18428
  Show dependency treegraph
 
Reported: 2012-05-10 08:09 UTC by Hayato Ito
Modified: 2012-07-27 22:37 UTC (History)
2 users (show)

See Also:


Attachments

Description Hayato Ito 2012-05-10 08:09:15 UTC
What should happen if a shadow root is attached to <content> (or <shadow>) elements?

According to the current spec, such insertion points select nodes, but these distributed nodes are not used in rendering. Instead, a shadow subree of InsertionPoint is used in rendering.

This is correct interpretation?
Comment 1 Dimitri Glazkov 2012-05-10 18:16:57 UTC
This is a very good question. Since we explicitly say that the insertion points are not rendered (not just their contents), it's not obvious what the behavior should be when you add a shadow DOM subtree to an insertion point.

We need to fix this bug in spec.

My inclination is to spec it the way WebKit implements it now: you can certainly add a shadow DOM subtree to an insertion point, but you will never be able to see it, since the insertion point itself is never rendered.

WDYT?
Comment 2 Dominic Cooney 2012-05-11 01:20:21 UTC
That interpretation sounds good to me.

Is it worth specifying what happens when you have a <content> element outside of Shadow DOM (ie not an insertion point) with a ShadowRoot? And what happens when it gets moved inside the ShadowRoot?
Comment 3 Hayato Ito 2012-05-11 01:55:12 UTC
+shinyak

As we discussed this with shinyak, we don't have any intentional explicit code which handles this case in current WebKit implementation. So just adapting the way WebKit implement is not appropriate.

I don't have any clear idea about which should be done in this case. IMO, my first interpretation is the best for us now if we don't have any alternative idea.
Comment 4 Dimitri Glazkov 2012-05-11 01:56:49 UTC
(In reply to comment #3)
> +shinyak
> 
> As we discussed this with shinyak, we don't have any intentional explicit code
> which handles this case in current WebKit implementation. So just adapting the
> way WebKit implement is not appropriate.
> 
> I don't have any clear idea about which should be done in this case. IMO, my
> first interpretation is the best for us now if we don't have any alternative
> idea.

Which one is the first idea?
Comment 5 Dominic Cooney 2012-05-11 01:58:28 UTC
It doesn’t matter if what WebKit does is deliberate or not… I believe it is just being an example of what the semantics should be.

I don’t like the suggested behavior in Comment 1 (if I understand it.) It seems inconsistent.
Comment 6 Hayato Ito 2012-05-11 04:40:11 UTC
In the current WebKit implementation:
  1. A shadow root attached to InsertionPoint is simply ignored and not used at all. InsertionPoints still works as InsertionPoint.
  2. We don't throw any exception when attaching a shadowRoot to insertionPoints.

For 1). it sounds reasonable for me.
For 2). It might be worth discussing whether we should throw exception or not.

(In reply to comment #5)
> It doesn’t matter if what WebKit does is deliberate or not… I believe it is
> just being an example of what the semantics should be.
> 
> I don’t like the suggested behavior in Comment 1 (if I understand it.) It seems
> inconsistent.
Comment 7 Hayato Ito 2012-05-11 04:54:00 UTC
Note that I've used a *active* InsertionPoint.
For inactive InsertionPoints, attaching a ShadowRoot does take effect.

(In reply to comment #6)
> In the current WebKit implementation:
>   1. A shadow root attached to InsertionPoint is simply ignored and not used at
> all. InsertionPoints still works as InsertionPoint.
>   2. We don't throw any exception when attaching a shadowRoot to
> insertionPoints.
> 
> For 1). it sounds reasonable for me.
> For 2). It might be worth discussing whether we should throw exception or not.
> 
> (In reply to comment #5)
> > It doesn’t matter if what WebKit does is deliberate or not… I believe it is
> > just being an example of what the semantics should be.
> > 
> > I don’t like the suggested behavior in Comment 1 (if I understand it.) It seems
> > inconsistent.
Comment 8 Dimitri Glazkov 2012-05-11 04:56:50 UTC
(In reply to comment #6)
> In the current WebKit implementation:
>   1. A shadow root attached to InsertionPoint is simply ignored and not used at
> all. InsertionPoints still works as InsertionPoint.

It's not ignored. Things just work exactly as expected. Since an active insertion point is not rendered, there's no way to render shadow dom subtree. It could totally be created and operated on. It's just never rendered.

>   2. We don't throw any exception when attaching a shadowRoot to
> insertionPoints.

Why would we throw an exception? It's similar to throwing an exception when you're trying to append a child to an element with style "display:none".

> 
> For 1). it sounds reasonable for me.
> For 2). It might be worth discussing whether we should throw exception or not.
> 
> (In reply to comment #5)
> > It doesn’t matter if what WebKit does is deliberate or not… I believe it is
> > just being an example of what the semantics should be.
> > 
> > I don’t like the suggested behavior in Comment 1 (if I understand it.) It seems
> > inconsistent.
Comment 9 Dominic Cooney 2012-05-11 05:04:40 UTC
I think we should not throw an exception, because we still have to deal with this case anyway:

<content id="a">
<div id="b">
<script>
var a = document.querySelector('#a');
var b = document.querySelector('#b');
var t = new ShadowRoot(a);
var u = new ShadowRoot(b);
a.parentNode.removeChild(a);
u.appendChild(a);
</script>

ie the ShadowRoot could be attached when the insertion point is inactive, and the insertion point could become active later.
Comment 10 Hayato Ito 2012-05-11 05:10:57 UTC
It seems you guys gave me comment when I was writing the followings: :)

My suggestions are:

- For active InsertionPoints, attached ShadowRoots should not be used.
- For inactive InsertionPoint, attached ShadowRoots should take effect.
- It is okay to attach a ShadowRoot to either active or inactive InsertionPoints.
- It is okay to move a InsertionPoint inside the ShadowRoot or outside the
ShadowRoot. That might change its active/inactive status, but that should not
get rid of its attached ShadowRoots.


(In reply to comment #9)
> I think we should not throw an exception, because we still have to deal with
> this case anyway:
> 
> <content id="a">
> <div id="b">
> <script>
> var a = document.querySelector('#a');
> var b = document.querySelector('#b');
> var t = new ShadowRoot(a);
> var u = new ShadowRoot(b);
> a.parentNode.removeChild(a);
> u.appendChild(a);
> </script>
> 
> ie the ShadowRoot could be attached when the insertion point is inactive, and
> the insertion point could become active later.
Comment 11 Hayato Ito 2012-05-11 05:16:09 UTC
So we don't have to change the current WebKit implementaton at all.

(In reply to comment #10)
> It seems you guys gave me comment when I was writing the followings: :)
> 
> My suggestions are:
> 
> - For active InsertionPoints, attached ShadowRoots should not be used.
> - For inactive InsertionPoint, attached ShadowRoots should take effect.
> - It is okay to attach a ShadowRoot to either active or inactive
> InsertionPoints.
> - It is okay to move a InsertionPoint inside the ShadowRoot or outside the
> ShadowRoot. That might change its active/inactive status, but that should not
> get rid of its attached ShadowRoots.
> 
> 
> (In reply to comment #9)
> > I think we should not throw an exception, because we still have to deal with
> > this case anyway:
> > 
> > <content id="a">
> > <div id="b">
> > <script>
> > var a = document.querySelector('#a');
> > var b = document.querySelector('#b');
> > var t = new ShadowRoot(a);
> > var u = new ShadowRoot(b);
> > a.parentNode.removeChild(a);
> > u.appendChild(a);
> > </script>
> > 
> > ie the ShadowRoot could be attached when the insertion point is inactive, and
> > the insertion point could become active later.
Comment 12 Shinya Kawanaka 2012-05-11 05:18:24 UTC
(In reply to comment #10)
> It seems you guys gave me comment when I was writing the followings: :)
> 
> My suggestions are:
> 
> - For active InsertionPoints, attached ShadowRoots should not be used.
> - For inactive InsertionPoint, attached ShadowRoots should take effect.
> - It is okay to attach a ShadowRoot to either active or inactive
> InsertionPoints.
> - It is okay to move a InsertionPoint inside the ShadowRoot or outside the
> ShadowRoot. That might change its active/inactive status, but that should not
> get rid of its attached ShadowRoots.
> 

The first bullet:
> For active InsertionPoints, attached ShadowRoots should not be used.
means:
  the ShadowRoot will not be rendered, 
  and the distribution algorithm for InsertionPoints will run,
right?

If so, I think these suggestions make sense.
Comment 13 Hayato Ito 2012-05-11 05:22:25 UTC
Yes, 

> - For active InsertionPoints, attached ShadowRoots should not be used.

'Should' might be confusing, the correct sentence is:

For active InsertionPoints, distributed nodes (if exist) are rendered. The InsertionPoint element itself is not rendered. As a result, its attached shadow roots are not used.


(In reply to comment #12)
> (In reply to comment #10)
> > It seems you guys gave me comment when I was writing the followings: :)
> > 
> > My suggestions are:
> > 
> > - For active InsertionPoints, attached ShadowRoots should not be used.
> > - For inactive InsertionPoint, attached ShadowRoots should take effect.
> > - It is okay to attach a ShadowRoot to either active or inactive
> > InsertionPoints.
> > - It is okay to move a InsertionPoint inside the ShadowRoot or outside the
> > ShadowRoot. That might change its active/inactive status, but that should not
> > get rid of its attached ShadowRoots.
> > 
> 
> The first bullet:
> > For active InsertionPoints, attached ShadowRoots should not be used.
> means:
>   the ShadowRoot will not be rendered, 
>   and the distribution algorithm for InsertionPoints will run,
> right?
> 
> If so, I think these suggestions make sense.
Comment 14 Dimitri Glazkov 2012-07-27 22:37:36 UTC
I let this slip through. Sorry!

Post-discussion, it appears that no changes are necessary to the spec. Right? If I am wrong, please re-open.