Skip to content

Commit 105b896

Browse files
committed
docs(targets): document shadowRoot capabilities
1 parent c1a201f commit 105b896

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

docs/_guide/targets.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ To clarify the difference between `@target` and `@targets` here is a handy table
121121
| `@target` | `querySelector` | `data-target="*"` | `Element` |
122122
| `@targets` | `querySelectorAll` | `data-targets="*"` | `Array<Element>` |
123123

124+
### Targets and "ShadowRoots"
125+
126+
Custom elements can create encapsulated DOM trees known as "Shadow" DOM. Catalyst targets support Shadow DOM by first traversing the `shadowRoot`, if present.
127+
128+
Important to note here is that nodes from the `shadowRoot` get returned _first_. So `@targets` will return an array of nodes, where shadowRoot nodes are at the start of the Array, and `@target` will return a ShadowRoot target if it exists, otherwise it will fall back to traversing the elements direct children.
129+
124130
### What about without Decorators?
125131

126132
If you're using decorators, then the `@target` and `@targets` decorators will turn the decorated properties into getters.

0 commit comments

Comments
 (0)