[w3c/webcomponents] Generic programs can't reliably use/manipulate documents via the DOM (#640)

*Alternative title*: **DOM does not reliably model document objects with closed shadow DOMs.**

A generic program (ie. a program that uses the DOM to interact with a document *of which it has no prior knowledge*) has no reliable interface with which it can interact with and/or monitor documents. In particular:
* the true active element in the document cannot be discovered when inside a closed shadow DOM. Thus,
  - the program cannot reason about the default action associated with eg. `keydown`, `keyup` and `click` events, and so cannot predict behaviour in response to user input or its own simulated input.
  - the program cannot reliably direct or redirect the focus of the page in order to perform further actions
  - a selection cannot be read (except as a string by `Selection.toString`) or modified (except by the non-standard [`Selection.modify`](https://developer.mozilla.org/en-US/docs/Web/API/Selection/modify))
* the contents of the shadow DOM are completely inaccessible to the program.
  - Since the program has no specific knowledge of the document, it cannot reason about it in any reliable way.
  - Further -- even when the document/component provides an API for (some of) its contents -- the program has no way of knowing that it exists or how to use it.
  - A user may expect (or even direct) the program to interact with a closed shadow DOM child, since there is no perceptible difference from a normal element to them.
* a program with access to the DOM but not the document's Javascript context cannot use any of the usually suggested techniques to circumvent this. Its only option is to proceed with broken or incomplete functionality.

Closed shadow DOMs may (or may not) be fine for document authors, who make the decision to use code including them. However, their existence and use makes the DOM an unreliable API for programs, libraries, etc. that are made to *act upon* a document by the user or document author.

If the DOM is supposed to be an effective API for developers other than document/component authors, then closed shadow DOMs are directly harmful. I propose depreciating `mode` and dropping closed shadow DOMs completely.

This issue generalises #354, all examples there also apply to here. (/cc @dylanb in case you're still interested).

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/640

Received on Monday, 8 May 2017 15:33:07 UTC