W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2015

Re: Imperative API for Node Distribution in Shadow DOM (Revisited)

From: Ryosuke Niwa <rniwa@apple.com>
Date: Sat, 25 Apr 2015 13:58:13 -0700
Cc: Anne van Kesteren <annevk@annevk.nl>, WebApps WG <public-webapps@w3.org>, Erik Bryn <erik@erikbryn.com>, Dimitri Glazkov <dglazkov@google.com>
Message-id: <03A5D7C9-0C67-4258-A285-2DCF6AFB015A@apple.com>
To: Olli Pettay <olli@pettay.fi>

> On Apr 25, 2015, at 1:17 PM, Olli Pettay <olli@pettay.fi> wrote:
> On 04/25/2015 09:28 AM, Anne van Kesteren wrote:
>> On Sat, Apr 25, 2015 at 12:17 AM, Ryosuke Niwa <rniwa@apple.com> wrote:
>>> In today's F2F, I've got an action item to come up with a concrete workable
>>> proposal for imperative API.  I had a great chat about this afterwards with
>>> various people who attended F2F and here's a summary.  I'll continue to work
>>> with Dimitri & Erik to work out details in the coming months (our deadline
>>> is July 13th).
>>> https://gist.github.com/rniwa/2f14588926e1a11c65d3
>> I thought we came up with something somewhat simpler that didn't
>> require adding an event or adding remove() for that matter:
>>   https://gist.github.com/annevk/e9e61801fcfb251389ef
> That is pretty much exactly how I was thinking the imperative API to work.
> (well, assuming errors in the example fixed)
> An example explaining how this all works in case of nested shadow trees would be good.
> I assume the more nested shadow tree just may get some nodes, which were already distributed, in the distributionList.

Right, that was the design we discussed.

> How does the distribute() behave? Does it end up invoking distribution in all the nested shadow roots or only in the callee?

Yes, that's the only reason we need distribute() in the first place.  If we didn't have to care about redistribution, simply exposing methods to insert/remove distributed nodes on content element is sufficient.

> Should distribute callback be called automatically at the end of the microtask if there has been relevant[1] DOM mutations since the last
> manual call to distribute()? That would make the API a bit simpler to use, if one wouldn't have to use MutationObservers.

That's a possibility.  It could be an option to specify as well.  But there might be components that are not interested in updating distributed nodes for the sake of performance for example.  I'm not certain forcing everyone to always update distributed nodes is necessarily desirable given the lack of experience with an imperative API for distributing nodes.

> [1] Assuming we want to distribute only direct children, then any child list change or any attribute change in the children
> might cause distribution() automatically.

I think that's a big if now that we've gotten rid of "select" attribute and multiple generations of shadow DOM.  As far as I could recall, one of the reasons we only supported distributing direct children was so that we could implement "select" attribute and multiple generations of shadow DOM.   If we wanted, we could always impose such a restriction in a declarative syntax and inheritance mechanism we add in v2 since those v2 APIs are supposed to build on top of this imperative API.

Another big if is whether we even need to let each shadow DOM select nodes to redistribute.  If we don't need to support filtering distributed nodes in insertion points for re-distribution (i.e. we either distribute everything under a given content element or nothing), then we don't need all of this redistribution mechanism baked into the browser and the model where we just have insert/remove on content element will work.

- R. Niwa
Received on Saturday, 25 April 2015 20:58:44 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:27:31 UTC