# svelte-actions-mutation

> MutationObserver action plugin for Svelte 3

Latest version **1.0.0** (published 2019-09-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install svelte-actions-mutation
pnpm add svelte-actions-mutation
yarn add svelte-actions-mutation
bun add svelte-actions-mutation
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2019-09-14 |
| First published | 2019-09-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | PaulMaly |
| Maintainers | paulmaly |
| Keywords | svelte, transitions, css, animation |

## Links

- npm: https://www.npmjs.com/package/svelte-actions-mutation
- Repository: https://github.com/PaulMaly/svelte-actions-mutation
- Homepage: https://github.com/PaulMaly/svelte-actions-mutation#readme
- Issues: https://github.com/PaulMaly/svelte-actions-mutation/issues
- npm.io page: https://npm.io/package/svelte-actions-mutation

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2019-09-14

## README

# svelte-actions-mutation

MutationObserver action plugin for [Svelte 3](https://svelte.dev). [Demo](https://svelte.dev/repl/ad0a323cbe6145fda049c5a884297b85?version=3.12.1)

## Usage

Install with npm or yarn:

```bash
npm install --save svelte-actions-mutation
```

```html
<button bind:this={btn} use:mutation={options} on:click={mutate}>
  Mutate
</button>

<script>
  import mutation from 'svelte-actions-mutation';
	
  let btn;

  function mutate() {
    btn.classList.add(Math.random().toString(36).substring(7));
  }
  
  const options = {
    attributeOldValue: true,
    attributeFilter: [ 'class' ],
    attributes(mutation) {
      console.log(`Attribute ${mutation.attributeName} mutated. Old value: ${mutation.oldValue}`);
	}
  };
</script>
```

## Options

| Name | Type | Description |
| --- | --- | --- |
| `attributes` | `Function` | Callback to watch for changes to the value of attributes on the node or nodes being monitored.  |
| `characterData` | `Function` | Callback to monitor the specified target node or subtree for changes to the character data contained within the node or nodes. |
| `childList` | `Function` | Callback to monitor the target node (and, if `subtree` is `true`, its descendants) for the addition of new child nodes or removal of existing child nodes.|
| `attributeFilter` | `Array` | An array of specific attribute names to be monitored. If this property isn't included, changes to all attributes cause mutation notifications. |
| `attributeOldValue` | `Boolean` | Set to true to record the previous value of any attribute that changes when monitoring the node or nodes for attribute changes. |
| `subtree` | `Boolean` | Set to true to extend monitoring to the entire subtree of nodes rooted at target.|
| `characterDataOldValue` | `Boolean` | Set to true to record the previous value of a node's text whenever the text changes on nodes being monitored. |

## License

MIT &copy; [PaulMaly](https://github.com/PaulMaly)

---
_Source: https://npm.io/package/svelte-actions-mutation · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
