Re: [webcomponents]: Allowing text children of ShadowRoot is a bad time

On Tue, Oct 8, 2013 at 11:04 PM, Hayato Ito <hayato@chromium.org> wrote:

> Good points. All you pointed out make sense to me.
>
> But I am wondering what we should do for these issues:
>
> A). Discourage developers to use direct text children of ShadowRoot.
> B). Disallow direct text children of ShadowRoot in the Shadow DOM spec.
> C). Find a nice way to style direct text children of ShadowRoot.
>
> Did you mean B?
>
>
I did mean B. ShadowRoot is very similar to Document which also disallows
direct Text children. All of the APIs we're putting on ShadowRoot are also
on Document so I think it makes sense for them to behave the same as well.

shadowRoot.appendChild(new Text("")) should probably throw an exception.


>
> On Wed, Oct 9, 2013 at 2:46 AM, Elliott Sprehn <esprehn@gmail.com> wrote:
>
>> Direct text children of ShadowRoot are full of sadness:
>>
>> 1) You can't call getComputedStyle on them since that's only allowed for
>> Elements, and the old trick of parentNode doesn't work since that's a
>> ShadowRoot. ShadowRoot doesn't expose a host property so I can't get
>> outside to find the host style that's inherited either. If the ShadowRoot
>> has resetStyleInheritance set then the text uses a "root default style",
>> but I have no way to get that as well.
>>
>> 2) There's no way to set the style of the Text. Normally I can do
>> parentNode.style.color = ...; but since ShadowRoot has no style property I
>> have no way to influence the text of the ShadowRoot without dynamically
>> changing a <style> element.
>>
>> 3) You can't use elementFromPoint(). It returns null since
>> ShadowRoot.elementFromPoint should always return an element in that scope,
>> but there is no element in that scope. This means you have no sensible way
>> to do a hit test of the text in the shadow root.
>>
>> - E
>>
>
>
>
> --
> Hayato
>

Received on Wednesday, 9 October 2013 21:55:08 UTC