---
name: "up.fragment.isAlive"
area: "API"
kind: "JavaScript function"
parent: "up.fragment module"
visibility: "experimental"
url: "https://unpoly.com/api/up.fragment.isAlive"
---
<nav aria-label="Unpoly docs">[All docs](https://unpoly.com/index.md) · [up.fragment module](https://unpoly.com/api/up.fragment.md)</nav>

# up.fragment.isAlive(fragment)

**This feature is experimental**. Please [share](https://github.com/unpoly/unpoly/discussions) your experiences so we know what to keep or change.

Returns whether the given fragment is both [attached to the DOM](https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected) and not currently in a destroy animation.

<nav aria-label="Contents">

#### Contents

- [Understanding aliveness](#understanding-aliveness)
- [See also](#see-also)
- [Parameters](#parameters)
- [Return value](#return-value)

</nav>

## Understanding aliveness {#understanding-aliveness}

A fragment that is alive can be [targeted](https://unpoly.com/learn/targeting-fragments.md), and can be discovered by [`up.fragment`](https://unpoly.com/api/up.fragment.md) functions.

A fragment becomes "unalive" immediately when it is destroyed, or when an ancestor is destroyed. If the destruction is [animated](https://unpoly.com/api/up.motion.md), the fragment is "unalive" while the animation is still playing.

| Element state | `up.fragment.isAlive(element)` |
| --- | --- |
| Entered DOM | `true` |
| Enter animation playing | `true` |
| Still element in the DOM | `true` |
| Exit animation playing | `false` |
| Removed from DOM | `false` |

## See also {#see-also}

- The [`.up-destroying`](https://unpoly.com/api/up-destroying.md) class is automatically assigned to elements in their exit animation.
- All [`up.fragment`](https://unpoly.com/api/up.fragment.md) functions (like [`up.fragment.get()`](https://unpoly.com/api/up.fragment.get.md)) ignore elements in their exit animation.
- The [`up.Layer#isAlive()`](https://unpoly.com/api/up.Layer.prototype.isAlive.md) method checks if an overlay is attached to the DOM and also not in a closing animation.

---

## Parameters {#parameters}

### fragment {#fragment}

(required)

The fragment to check.

Type: [Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)

---

## Return value {#return-value}

Whether the fragment (and its ancestors) are considered alive.

Type: boolean

