A component offset counts the elements before a fragment-based component view in its parent element. It equals the index of the component’s first element there. section 9.3.3
Fragment-relative indices do not include elements outside the component. Adding the offset converts move and add indices into parent-element indices. section 9.3.3 section 9.3.4
Implement the correction in two small steps:
- Expose the component’s elements, first element, and offset; return zero when no host component exists. section 9.3.3 section 9.3.4
- Pass the host component into patchDOM() and add its offset only to move and add indices. section 9.3.4
- Leave remove and noop operations unadjusted because they do not address DOM nodes by index. section 9.3.4
Offset of one
If a component’s first element is the second child of its parent, its offset is 1. A fragment-relative move from index 1 to index 0 becomes a parent-relative move from index 2 to index 1. section 9.3.3 section 9.3.4
Figure 9.10 The offset of the component is 1.
Use the figure to see the component’s first fragment element positioned after one external parent element. section 9.3.3
