[whatwg/dom] `compareDocumentPosition` should allow comparison of elements in the same shadow-including root (#320)

(Some discussion on this already happened in #309.)

https://dom.spec.whatwg.org/#dom-node-comparedocumentposition

`compareDocumentPosition` should be able to compare nodes with different roots if those nodes have the same shadow-including root and the user indicates they would like to compare using the composed tree.

Consider:
```html
<div>
  <!-- ShadowRoot -->
    <slot></slot>
    <div id="A"></div>
  <!-- /ShadowRoot -->
  <div id="B"></div>
</div>
```
which composes to something 'like':
```html
<div>
  <!-- ShadowRoot -->
    <slot>
      <div id="B"></div>
    </slot>
    <div id="A"></div>
  <!-- /ShadowRoot -->
</div>
```

`A.compareDocumentPosition(B, {composed: true});`, or something similar, should return `DOCUMENT_POSITION_PRECEDING`.

A strange situation this brings up is how fallback content of a slot compare to other nodes in the same shadow-including root when that slot has assigned nodes. IMHO, when comparing using the composed tree, the slot's fallback content should be considered disconnected.

Also, given that a ShadowRoot doesn't have a natural position in its host's tree (or relative to its host's descendants - it's not a special child) without composition, I think step 6 in the specced behavior should continue to apply if no explicit opt-in is indicated.

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

Received on Tuesday, 30 August 2016 22:58:32 UTC