/
index.md
52 lines (35 loc) · 1.33 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
---
title: "HTMLSlotElement: assignedElements() method"
short-title: assignedElements()
slug: Web/API/HTMLSlotElement/assignedElements
page-type: web-api-instance-method
browser-compat: api.HTMLSlotElement.assignedElements
---
{{APIRef("Shadow DOM API")}}
The **`assignedElements()`** method of the {{domxref("HTMLSlotElement")}}
interface returns a sequence of the elements assigned to this slot (and no
other nodes).
If the `flatten` option is set to `true`, it returns a sequence of both the elements assigned to this slot, as well as the elements assigned to any other slots that are descendants of this slot. If no assigned elements are found, it returns the slot's fallback content.
## Syntax
```js-nolint
assignedElements()
assignedElements(options)
```
### Parameters
- `options` {{optional_inline}}
- : An object that sets options for the nodes to be returned. The available options are:
- `flatten`
- : A boolean value indicating whether to return the
assigned elements of any available child `<slot>` elements
(`true`) or not (`false`). Defaults to `false`.
### Return value
An array of elements.
## Examples
```js
let slots = this.shadowRoot.querySelector("slot");
let elements = slots.assignedElements({ flatten: true });
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}