Security News
cURL Project and Go Security Teams Reject CVSS as Broken
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
qsa-observer
Advanced tools
A way to be notified about any element that was connected, or disconnected, from a container.
A way to be notified about any element that was connected, or disconnected, from a container.
setup(element, selector)
utility, and per each matching selectorinnerHTML
, within nested elements, will be parsed tooupdate(element, connected)
utilityimport 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 {
matches, // an utility to retrieve the matches method of a generic element
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
// either a (weak) Set or Map to flag elements as already setup
cache: new WeakSet,
// invoked when a new element (not in cache) is connected
setup(element, selector) {
// prevents the element from passing through a setup next time
this.cache.add(element);
console.log(element, selector, 'initialized');
// pass through the connected dance, if necessary, as the setup
// occurs only when an element is being connected, but no update
// would happen in such case, as the setup can optionally take care of it
this.update(element, true);
},
// invoked when a known element (in cache) changes state
update(element, connected) {
console.log(element, connected ? 'connected' : 'disconnected');
}
});
// example: add another selector to observe and passes through the setup
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
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
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
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.