New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

element-mutator-lib

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

element-mutator-lib

It is a wrapper around MutationObserver and it provide more convenient way to track DOM node mutations.

latest
Source
npmnpm
Version
1.0.11
Version published
Maintainers
1
Created
Source

Not for a production!

It is for my "home" project and it has not unit tests and it is my playground. I strongly recommend to don't use it in production.

Installation

npm install element-mutator-lib

How to use

Example 1. Run after page is loaded and track all DOM changes.

import ElementMutator from 'element-mutator-lib';

const elementMutator = new ElementMutator({attributeFilter: []}, (cfg, node, attributeName) => {
    // do something
    elementMutator.stop(); // stop
});

Example 2. Track a specific DOM node and all his descendants (<body> body tag in that case).

import ElementMutator from 'element-mutator-lib';

const elementMutator = new ElementMutator({attributeFilter: [], node: document.body}, (cfg, node, attributeName) => {
    // do something
    elementMutator.stop(); // stop
});

Example 3. Track a specific DOM node attributes (href attribute in that case). If attributeName is undefined then mutation is a non attribute mutation.

import ElementMutator from 'element-mutator-lib';

const elementMutator = new ElementMutator({attributeFilter: [href]}, (cfg, node, attributeName) => {
    // do something
    elementMutator.stop(); // stop
});

FAQs

Package last updated on 29 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts