New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@sheerun/mutationobserver-shim

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sheerun/mutationobserver-shim

MutationObserver shim for ES3 environments

  • 0.3.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
302K
increased by0.88%
Maintainers
1
Weekly downloads
 
Created

What is @sheerun/mutationobserver-shim?

@sheerun/mutationobserver-shim is a polyfill for the MutationObserver API, which allows you to watch for changes being made to the DOM tree. This is particularly useful for environments where MutationObserver is not natively supported.

What are @sheerun/mutationobserver-shim's main functionalities?

Observing DOM Changes

This feature allows you to observe changes to the DOM, such as additions or removals of child nodes, or modifications to attributes. The code sample demonstrates how to set up a MutationObserver to watch for these changes and log them to the console.

const MutationObserver = require('@sheerun/mutationobserver-shim');

const targetNode = document.getElementById('someElement');
const config = { attributes: true, childList: true, subtree: true };

const callback = function(mutationsList, observer) {
  for(const mutation of mutationsList) {
    if (mutation.type === 'childList') {
      console.log('A child node has been added or removed.');
    }
    else if (mutation.type === 'attributes') {
      console.log('The ' + mutation.attributeName + ' attribute was modified.');
    }
  }
};

const observer = new MutationObserver(callback);
observer.observe(targetNode, config);

Other packages similar to @sheerun/mutationobserver-shim

Keywords

FAQs

Package last updated on 09 Mar 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc