Re: [webcomponents] Making the shadow root an Element

On Sat, Feb 16, 2013 at 9:23 AM, Dimitri Glazkov <dglazkov@google.com> wrote:
> Thank you for enumerating the list, Jonas!
>
> On Thu, Feb 14, 2013 at 11:12 PM, Jonas Sicking <jonas@sicking.cc> wrote:
>
>>
>> I chatted with Blake about this today and had some thoughts.
>>
>> There is definitely no simple answer here, feels like using either an
>> Element or a DocumentFragment has some crappy behavior. So it's a
>> matter of choosing the less crappy option.
>>
>> Pros of using a DocumentFragment:
>> * Avoids the problem of what to do if someone sets a style attribute
>> on the shadow root, or otherwise attempts to style it. Currently the
>> shadow root doesn't appear in the flattened tree (though we could
>> maybe change that) which means that it can't be styled. This is
>> intuitive if the shadow root is a DocumentFragment but not so much if
>> it is an Element.
>
> We will have this problem with other elements as soon as there's
> "display: contents"  is implemented.

Good point.

>> Pros of using an Element:
>> * Does mean that a lot of code which is used to dealing with just
>> Elements and Text nodes will "just work". For example jQuery code
>> freaked out [1] over hitting a node that wasn't an Element but still
>> had an innerHTML property. There will likely be other code that does
>> the same.
>
> We were thinking of adding innerHTML to DocumentFragments anyway... right, Anne?

Sure, but the point is that there's lots of code out there that
doesn't expect to be interacting with DocumentFragments. Or at least
isn't expecting DocumentFragments to have the same feature set as
Elements. That was the problem in the jQuery case.

>> * Means that you can set attributes on the shadow root. Again, this is
>> likely something libraries will do as they walk around in subtrees.
>> Especially if they weren't written with the existence of shadow trees
>> in mind (i.e. all the time).
>
> I don't know if this is a pro. The attributes are pretty meaningless
> on a shadow root.

How so? Just because an element isn't rendered doesn't mean that it's
attributes are meaningless.

/ Jonas

Received on Sunday, 17 February 2013 06:58:16 UTC