Browser discussions on selection serialization and shadow DOM

I’d like to raise awareness of a discussion that the members of this group may be interested in (https://github.com/w3c/webcomponents/issues/79). Ryosuke Niwa and Takayoshi Kochi, representatives of Apple Safari / WebKit and Google Chrome / Blink respectively, have started to discuss a matter relevant to the Web Annotations standards, particularly their Selectors.

Shadow DOM (https://www.w3.org/TR/shadow-dom/) is a new W3C standard that has, after many years of spirited debate, been finalized and already shipped in Safari and Chrome for the past year; it is in active development in Mozilla Firefox. Niwa explains (https://webkit.org/blog/4096/introducing-shadow-dom-api/):

‘Shadow DOM is a part of Web Components, a set of specifications that were initially proposed by Google to enable the creation of reusable widgets and components on the Web. Shadow DOM, in particular, provides a lightweight encapsulation for DOM trees by allowing a creation of a parallel tree on an element called a “shadow tree” that replaces the rendering of the element without modifying the underlying DOM tree. Because a shadow tree is not an ordinary child of the “host” element to which it is attached, users of components cannot accidentally poke into it. Style rules are also scoped, meaning that CSS rules defined outside of a shadow tree do not apply to elements inside the shadow tree and rules defined inside the shadow tree do not apply to elements outside of it.’

Shadow DOM has obvious ramifications for Web Annotations. A user may select content in a shadow-DOM node, but how may that selection be targeted by an annotation, if the shadow DOM is hidden from the document context?

Two browser makers (Apple and Google) are now discussing this very question. They are, in fact, discussing a “mechanism to refer to a specific position within a shadow DOM with a mechanism that can be also used to refer to a specific position in pseudo element, SVG use element's shadow tree, etc.” as well as “saving / restoring selection states (ie. serializable selection)”, which is one of the “biggest request from web-based editor authors”. This is the start of a new DOM standard—whose design is likely to make implementing and serializing Web Annotations in web browsers (especially in shadow DOM) much easier or more difficult—depending on how well it maps to the Web Annotation Data Model.

As the authors of the Web Annotation specifications, this group is a stakeholder in serializing selections on the web platform and targeting selections in DOM, including shadow DOM. It thus may be in this group’s interest to monitor this conversation (https://github.com/w3c/webcomponents/issues/79) and make sure that the browser developers are aware of use cases for annotations. I don’t know the best way in doing this except for simply staying abreast of the conversation and perhaps chiming in on its GitHub issue. I may make a comment in the thread myself, soon. I may also open a GitHub issue in the Web Annotation repository (https://github.com/w3c/web-annotation/) about shadow-DOM selections.

Warm regards,
J. S. Choi
Saint Louis University
School of Medicine

Received on Thursday, 16 November 2017 10:33:20 UTC