[w3c/webcomponents] [idea] [shadow-dom] Provide a version number on shadow roots so they can be distinguished. (#610)

For example, `root.version`should return `0` if the root was created with `createShadowRoot()`, `1` or `2` if it was created with `attachShadow` and is one or the other.

I am making a library, and I'd like for that library to work with roots of varying versions while the API stabilizes (it is currently possible in Chrome to create v0 or v1 roots and my library can't assume which version the end user uses). For example:

```js
if (getShadowRootVersion(root) == 'v0') {
    // find and observe <content> elements
}
else if (getShadowRootVersion(root) == 'v1') {
    // find and observe <slot> elements
}

if (getShadowRootVersion(root) == 'v1' || getShadowRootVersion(root) == 'v2') {
    // use slot.assignedNodes()
}

if (getShadowRootVersion(root) == 'v2') {
    // use slot.assignedElements()
}
```

-- 
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/610

Received on Wednesday, 23 November 2016 20:25:57 UTC