> On Apr 27, 2015, at 4:41 PM, Steve Orvell <sorv...@google.com> wrote:
>> Again, the timing was deferred in [1] and [2] so it really depends on when 
>> each component decides to distribute.
> I want to be able to create an element <x-foo> that acts like other dom 
> elements. This element uses Shadow DOM and distribution to encapsulate its 
> details.
> Let's imagine a 3rd party user named Bob that uses <div> and <x-foo>. Bob 
> knows he can call div.appendChild(element) and then immediately ask 
> div.offsetHeight and know that this height includes whatever the added 
> element should contribute to the div's height. Bob expects to be able to do 
> this with the <x-foo> element also since it is just another element from his 
> perspective.
> How can I, the author of <x-foo>, craft my element such that I don't violate 
> Bob's expectations? Does your proposal support this?

In order to support this use case, the author of x-foo must use some mechanism 
to observe changes to x-foo's child nodes and involve `distribute` 
synchronously.  This will become possible, for example, if we added 
childrenChanged lifecycle callback to custom elements.

That might be an acceptable mode of operations. If you wanted to synchronously 
update your insertion points, rely on custom element's lifecycle callbacks and 
you can only support direct children for distribution. Alternatively, if you 
wanted to support to distribute a non-direct-child descendent, just use 
mutation observers to do it at the end of a micro task.

- R. Niwa

Reply via email to