{"action":"created","issue":{"url":"https://api.github.com/repos/w3c/webcomponents/issues/499","repository_url":"https://api.github.com/repos/w3c/webcomponents","labels_url":"https://api.github.com/repos/w3c/webcomponents/issues/499/labels{/name}","comments_url":"https://api.github.com/repos/w3c/webcomponents/issues/499/comments","events_url":"https://api.github.com/repos/w3c/webcomponents/issues/499/events","html_url":"https://github.com/w3c/webcomponents/issues/499","id":154242010,"number":499,"title":"Alternative proposal for closed shadow DOM","user":{"login":"mrmr1993","id":1847343,"avatar_url":"https://avatars.githubusercontent.com/u/1847343?v=3","gravatar_id":"","url":"https://api.github.com/users/mrmr1993","html_url":"https://github.com/mrmr1993","followers_url":"https://api.github.com/users/mrmr1993/followers","following_url":"https://api.github.com/users/mrmr1993/following{/other_user}","gists_url":"https://api.github.com/users/mrmr1993/gists{/gist_id}","starred_url":"https://api.github.com/users/mrmr1993/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrmr1993/subscriptions","organizations_url":"https://api.github.com/users/mrmr1993/orgs","repos_url":"https://api.github.com/users/mrmr1993/repos","events_url":"https://api.github.com/users/mrmr1993/events{/privacy}","received_events_url":"https://api.github.com/users/mrmr1993/received_events","type":"User","site_admin":false},"labels":[{"id":217336260,"url":"https://api.github.com/repos/w3c/webcomponents/labels/shadow-dom","name":"shadow-dom","color":"207de5","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":45,"created_at":"2016-05-11T13:21:14Z","updated_at":"2016-12-06T07:06:37Z","closed_at":"2016-12-06T07:06:37Z","body":"The `closed` flag for web components doesn't seem to have a clear purpose, and has several issues.\n## Security:\n- Current security of closed components from the page is illusory\n  - A page can hijack the registration of closed components (via https://github.com/w3c/webcomponents/issues/354#issuecomment-162383744) with\n\n``` js\nvar originalAttachShadow = Element.prototype.attachShadow;\nElement.prototype.attachShadow = function(options) {\n    options['mode'] = 'open';\n    return originalAttachShadow(options);\n}\n```\n- They share a javascript context with the main page, so there's a reasonable chance of accidentally leaking the shadow DOM.\n  - hooking `Element.prototype.addEventListener` is an easy example, and can't be closed without some webcompat breakage.\n  - The [`Proxy`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Proxy) object provides similar opportunities when hooking getters.\n- Security is asymmetric.\n  - The host page has to implicitly trust the component with its important data (session cookies, password fields, etc.).\n  - The host page cannot easily place any restrictions on the behaviour of the scripts governing the component.\n## Integrity:\n- As above, the shared javascript context creates ample opportunity for leaking the shadow DOM.\n- The host page has no guarantees that the web component code will not interfere with the it outside of  the component element.\n## Automation, accessibility & testing:\n- Currently spec breaks all of these. See #354.\n\nTaking these into account, it seems that a closed shadow DOM is little better than an open shadow DOM in any of the aspects it might hope to be, and causes problems for outside interaction with pages.\n## Proposed alternative:\n- Keep majority of shadow DOM spec.\n- Remove `ShadowRootMode` and all of its consequences from the shadow DOM spec.\n- Introduce a new element (say `<component-iframe>`) with the same attributes, DOM interfaces and behaviour as  `<iframe>`, except\n  - children of `<component-iframe>` are assigned to `<slot>`s in the document tree of the `<iframe>` using analogues of the [slotting algorithm (§3.2)](https://w3c.github.io/webcomponents/spec/shadow/#h-slotting-algorithm), [assigned nodes algorithm (§3.3)](https://w3c.github.io/webcomponents/spec/shadow/#assigned-nodes-algorithm), and [distributed nodes algorithm (§3.4)](https://w3c.github.io/webcomponents/spec/shadow/#h-distributed-nodes-algorithm).\n  - a DOM interface is added to the `<component-iframe>`'s `window` for registering API functions for the component, e.g.\n    - `window.registerComponentMethod(name, apiFunction)` to add a method\n    - `window.unregisterComponentMethod(name, apiFunction)` to remove a previously added method (functionally similar to `removeEventListener` elsewhere).\n  - a DOM interface is added to the `<component-iframe>` `HTMLElement` for accessing the registered API, e.g.\n    - `HTMLComponentIframeElement.getRegisteredComponentMethods()` to list the added methods\n    - `HTMLComponentIframeElement.NAME(...)` where `NAME` is the `name` argument for a method added via `registerComponentMethod`.\n  - the `<component-iframe>` should begin loading before being inserted into the document\n    - this allows it to process API calls, perform initialisation, etc. before it is displayed to the user.\n    - this could be achieved by adding a `load` method to `<component-iframe>` which creates the _nested browsing context_ (which persists after insertion into/removal from a document) and _processes the iframe attributes_ (see [iframe spec](https://dev.w3.org/html5/spec-preview/the-iframe-element.html)).\n    - this allows the component respond to API calls and perform initialisation before it is inserted into the document, if necessary.\n\nIs this reasonable or even doable as an alternative?\n\n/cc @dylanb, you're the major voice against closed shadow DOMs in #354. Would this proposal address your concerns/is it something you could get behind?\n"},"comment":{"url":"https://api.github.com/repos/w3c/webcomponents/issues/comments/265077060","html_url":"https://github.com/w3c/webcomponents/issues/499#issuecomment-265077060","issue_url":"https://api.github.com/repos/w3c/webcomponents/issues/499","id":265077060,"user":{"login":"hayatoito","id":160288,"avatar_url":"https://avatars.githubusercontent.com/u/160288?v=3","gravatar_id":"","url":"https://api.github.com/users/hayatoito","html_url":"https://github.com/hayatoito","followers_url":"https://api.github.com/users/hayatoito/followers","following_url":"https://api.github.com/users/hayatoito/following{/other_user}","gists_url":"https://api.github.com/users/hayatoito/gists{/gist_id}","starred_url":"https://api.github.com/users/hayatoito/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hayatoito/subscriptions","organizations_url":"https://api.github.com/users/hayatoito/orgs","repos_url":"https://api.github.com/users/hayatoito/repos","events_url":"https://api.github.com/users/hayatoito/events{/privacy}","received_events_url":"https://api.github.com/users/hayatoito/received_events","type":"User","site_admin":false},"created_at":"2016-12-06T07:06:37Z","updated_at":"2016-12-06T07:06:37Z","body":"I am triaging open issues. Let me close this issue since it looks this issue no longer gets much attention."}}
{"actor":{"display_login":"hayatoito"}}