npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@georapbox/mutation-observer-element

v2.0.1

Published

A custom element that offers a declarative interface to the MutationObserver API.

Downloads

9

Readme

npm version npm license

<mutation-observer>

A custom element that offers a declarative interface to the MutationObserver API.

API documentationDemo

Install

$ npm install --save @georapbox/mutation-observer-element

Usage

Script

import { MutationObserverElement } from './node_modules/@georapbox/mutation-observer-element/dist/mutation-observer.js';

// Manually define the element.
MutationObserverElement.defineCustomElement();

Alternatively, you can import the automatically defined custom element.

import './node_modules/@georapbox/mutation-observer-element/dist/mutation-observer-defined.js';

Markup

<mutation-observer 
  attr="*"
  attr-old-value
  char-data
  char-data-old-value
  child-list
>
  <button class="btn-primary">Click to mutate me</button>
</mutation-observer>

API

Properties

| Name | Reflects | Type | Default | Description | | ---- | -------- | ---- | ------- | ----------- | | attr | ✓ | String | "" | A space-separated string of attribute names to monitor (e.g., "title class href"). Use "*" to monitor all attributes. | | attrOldValueattr-old-value | ✓ | Boolean | false | Set to true to record the previous value of any attribute that changes when monitoring the node or nodes for attribute changes. | | childListchild-list | ✓ | Boolean | false | Set to true to monitor the target node for the addition of new child nodes or removal of existing child nodes. | | charDatachar-data | ✓ | Boolean | false | Set to true to monitor the specified target node for changes to the character data contained within the node or nodes. | | charDataOldValuechar-data-old-value | ✓ | Boolean | false | Set to true to record the previous value of a node's text whenever the text changes on nodes being monitored. | | disabled | ✓ | Boolean | false | Set to true to stop monitoring for mutations. |

NOTE: From the properties above, at least one of attr, child-list or char-data must be present, otherwise, no changes are monitored and no mutation events are emitted.

Slots

| Name | Description | | ---- | ----------- | | (default) | The default slot where the target node or nodes to be monitored are placed. |

Methods

| Name | Type | Description | Arguments | | ---- | ---- | ----------- | --------- | | defineCustomElement | Static | Defines/registers the custom element with the name provided. If no name is provided, the default name is used. The method checks if the element is already defined, hence will skip trying to redefine it. | elementName='mutation-observer' |

Events

| Name | Description | Event Detail | | ---- | ----------- | ------------ | | mutation-observer:mutate | Emitted when the element is mutated. | { mutationList: MutationRecord[] |

Changelog

For API updates and breaking changes, check the CHANGELOG.

Development setup

Prerequisites

The project requires Node.js and npm to be installed on your environment. Preferrably, use nvm Node Version Manager and use the version of Node.js specified in the .nvmrc file by running nvm use.

Install dependencies

Install the project dependencies by running the following command.

npm install

Build for development

Watch for changes and start a development server by running the following command.

npm start

Linting

Lint the code by running the following command.

npm run lint

Testing

Run the tests by running any of the following commands.

npm test
npm run test:watch # watch mode

Build for production

Create a production build by running the following command.

npm run build

License

The MIT License (MIT)