Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
qsa-observer
Advanced tools
Social Media Photo by Kevin Maillefer on Unsplash
Given an array of selectors, handles any matching element that was either connected, or disconnected, from an observed element, or document.
handle(element, connected, selector)
utility, per each matching selectorinnerHTML
, or created offline, will be handled too once liveimport QSAO from 'qsa-observer';
// an Array of CSS selectors to observe
const query = ['div'];
// where to observe mutations, document by default
const root = document;
const {
drop, // an utility to drop a list of elements from being considered live
flush, // an utility to flush synchronously all queued mutations
observer, // the MutationObserver created by QSAO(...)
parse // an utility to parse new elements
// (i.e. after adding a selector to the query list)
} = QSAO({
query, // list of selectors to observe
root, // optional, as it's document by default
// the method that receives all elements that match one or more
// selectors in the query, and are either connected or disconnected
handle(element, connected, selector) {
const event = connected ? 'connected' : 'disconnected';
console.log(element, event, selector);
}
});
// example: add another selector to observe and pass through the handle
const observeMore = selector => {
if (!query.includes(selector)) {
query.push(selector);
parse(root.querySelectorAll(selector));
}
};
// example: watch 'p' nodes too after a second
setTimeout(observeMore, 1000, 'p');
FAQs
handle elements lifecycle through CSS selectors
The npm package qsa-observer receives a total of 219 weekly downloads. As such, qsa-observer popularity was classified as not popular.
We found that qsa-observer 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.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.