Intent to implement: Shadow DOM imperative distributed API

78 views
Skip to first unread message

Hayato Ito

unread,
Jul 31, 2018, 5:57:33 AM7/31/18
to blink-dev, Kyoko Muto
Contact emails

Explainer

This idea is very early-stage and has not yet settled down enough for a specification.

Summary
Let web developers specify node-to-slot assignments imperatively.
The design and API surface is very tentative. We will be exploring many different choices behind a flag to see what makes the most sense, before we work on standardization and eventually shipping.

Motivation
One of the drawbacks of Shadow DOM v1, when compared to Shadow DOM v0, is that web developers have to specify slot= attribute for every shadow host's children (except for elements for the *default* slot).

e.g.
<shadow-host>
  <div slot=slot1></div>
  <div slot=slot2></div>
</shadow-host>

- Some people would see this as a kind of *ugly* markup.
- Shadow DOM v1 can't explain how <summary>/<details> elements can be implemented on the top of the current Web Components technology stack, given that <details> element doesn't need slot= attribute.
  Blink has a special logic for some built-in elements to control node-to-slot mapping.

With the new imperative APIs, web developwrs don't have to put slot="" attributes everywhere; they can specify node-to-slot assignments imperatively, getting much clearner markup and flexibility.

As an additional bonus for Blink's codebase, it is likely that we can re-use the same *backend* of new APIs for built-in elements too, getting better code modularity and removing the existing special logic.


Compatibility risk
This feature is early stage and implementing it is intended to give us insight into these risks as developers experiment with it.
In particular, we are going to spend a lot of time figuring out what impacts the new APIs would have on existing declarative APIs.

Interoperability risk
- Edge: No public signals
- Firefox: No public signals
- Safari: Would help us to explore this problem space for a better API
- Web developers: No signals

Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?
Yes.

OWP launch tracking bug

Link to entry on the feature dashboard

Requesting approval to ship?
No.

--
Hayato
Reply all
Reply to author
Forward
0 new messages