@empathyco/x-components
Version:
Empathy X Components
61 lines (29 loc) • 1.14 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [getTargetElement](./x-components.gettargetelement.md)
## getTargetElement() function
Returns the target element for a given event. The target element is obtained from `composedPath` Event method because if the event is triggered inside a Shadow DOM context, `event.target` points to Shadow DOM element, not the element that triggered the event. `composedPath` method also is available in a non-shadow DOM context.
**Signature:**
```typescript
export declare function getTargetElement(event: Event): Element;
```
## Parameters
<table><thead><tr><th>
Parameter
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
event
</td><td>
Event
</td><td>
Event which takes place in the DOM.
</td></tr>
</tbody></table>
**Returns:**
Element
Target Element of the event.
## Remarks
In a shadow DOM context, this function only works if the Shadow DOM uses `open` encapsulation mode.