Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
mutationobserver-shim
Advanced tools
The mutationobserver-shim package 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 the native MutationObserver is not available.
Observing attribute changes
This feature allows you to observe changes to attributes of a DOM element. The provided code sample sets up a MutationObserver to watch for attribute changes on an element with the ID 'some-id'.
const targetNode = document.getElementById('some-id');
const config = { attributes: true };
const callback = function(mutationsList, observer) {
for(let mutation of mutationsList) {
if (mutation.type === 'attributes') {
console.log('The ' + mutation.attributeName + ' attribute was modified.');
}
}
};
const observer = new MutationObserver(callback);
observer.observe(targetNode, config);
Observing child list changes
This feature allows you to observe changes to the child nodes of a DOM element. The provided code sample sets up a MutationObserver to watch for additions or removals of child nodes on an element with the ID 'some-id'.
const targetNode = document.getElementById('some-id');
const config = { childList: true };
const callback = function(mutationsList, observer) {
for(let mutation of mutationsList) {
if (mutation.type === 'childList') {
console.log('A child node has been added or removed.');
}
}
};
const observer = new MutationObserver(callback);
observer.observe(targetNode, config);
Observing subtree changes
This feature allows you to observe changes to the entire subtree of a DOM element. The provided code sample sets up a MutationObserver to watch for additions or removals of child nodes within the subtree of an element with the ID 'some-id'.
const targetNode = document.getElementById('some-id');
const config = { subtree: true, childList: true };
const callback = function(mutationsList, observer) {
for(let mutation of mutationsList) {
if (mutation.type === 'childList') {
console.log('A child node has been added or removed in the subtree.');
}
}
};
const observer = new MutationObserver(callback);
observer.observe(targetNode, config);
The mutation-observer package is another polyfill for the MutationObserver API. It provides similar functionality to mutationobserver-shim, allowing you to observe changes to the DOM tree. Both packages aim to provide a consistent API for environments where the native MutationObserver is not available.
The mutation-summary package provides a higher-level API for observing changes to the DOM. It allows you to specify queries to observe and provides summaries of the changes. This package offers more advanced features compared to mutationobserver-shim, but it may be more complex to use.
###Compiled files
Compiled by Google closure compiler in ADVANCED_OPTIMIZATIONS
FAQs
MutationObserver shim for ES3 environments
The npm package mutationobserver-shim receives a total of 140,668 weekly downloads. As such, mutationobserver-shim popularity was classified as popular.
We found that mutationobserver-shim demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.