Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

qsa-observer

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qsa-observer - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

11

cjs/index.js

@@ -16,2 +16,6 @@ 'use strict';

};
const drop = elements => {
for (let i = 0, {length} = elements; i < length; i++)
live.delete(elements[i]);
};
const flush = () => {

@@ -22,2 +26,3 @@ callback(observer.takeRecords());

for (let selectors, element, i = 0, {length} = elements; i < length; i++) {
// guard against repeated elements within nested querySelectorAll results
if (!set.has(element = elements[i])) {

@@ -31,2 +36,3 @@ set.add(element);

selectors = live.get(element);
// guard against selectors that were handled already
if (!selectors.has(q)) {

@@ -39,2 +45,3 @@ selectors.add(q);

}
// guard against elements that never became live
else if (live.has(element)) {

@@ -44,3 +51,3 @@ selectors = live.get(element);

selectors.forEach(q => {
options.handle(element, connected, selectors[i]);
options.handle(element, connected, q);
});

@@ -66,3 +73,3 @@ }

parse(root.querySelectorAll(query));
return {flush, observer, parse};
return {drop, flush, observer, parse};
};

2

es.js

@@ -1,1 +0,1 @@

self.qsaObserver=function(e){"use strict";const t=e=>"querySelectorAll"in e,{filter:r}=[];return e.default=e=>{const l=new WeakMap,s=l=>{const{query:s}=e;if(s.length)for(let e=0,{length:o}=l;e<o;e++)a(r.call(l[e].addedNodes,t),!0,s),a(r.call(l[e].removedNodes,t),!1,s)},a=(t,r,s,n=new Set)=>{for(let c,d,h=0,{length:u}=t;h<u;h++)if(!n.has(d=t[h])){if(n.add(d),r)for(let t,a=o(d),n=0,{length:h}=s;n<h;n++)a.call(d,t=s[n])&&(l.has(d)||l.set(d,new Set),c=l.get(d),c.has(t)||(c.add(t),e.handle(d,r,t)));else l.has(d)&&(c=l.get(d),l.delete(d),c.forEach(t=>{e.handle(d,r,c[h])}));a(d.querySelectorAll(s),r,s,n)}},o=e=>e.matches||e.webkitMatchesSelector||e.msMatchesSelector,n=(t,r=!0)=>{a(t,r,e.query)},c=new MutationObserver(s),d=e.root||document,{query:h}=e;return c.observe(d,{childList:!0,subtree:!0}),h.length&&n(d.querySelectorAll(h)),{flush:()=>{s(c.takeRecords())},observer:c,parse:n}},e}({}).default;
self.qsaObserver=function(e){"use strict";const t=e=>"querySelectorAll"in e,{filter:l}=[];return e.default=e=>{const r=new WeakMap,s=r=>{const{query:s}=e;if(s.length)for(let e=0,{length:a}=r;e<a;e++)o(l.call(r[e].addedNodes,t),!0,s),o(l.call(r[e].removedNodes,t),!1,s)},o=(t,l,s,n=new Set)=>{for(let c,d,h=0,{length:u}=t;h<u;h++)if(!n.has(d=t[h])){if(n.add(d),l)for(let t,o=a(d),n=0,{length:h}=s;n<h;n++)o.call(d,t=s[n])&&(r.has(d)||r.set(d,new Set),c=r.get(d),c.has(t)||(c.add(t),e.handle(d,l,t)));else r.has(d)&&(c=r.get(d),r.delete(d),c.forEach(t=>{e.handle(d,l,t)}));o(d.querySelectorAll(s),l,s,n)}},a=e=>e.matches||e.webkitMatchesSelector||e.msMatchesSelector,n=(t,l=!0)=>{o(t,l,e.query)},c=new MutationObserver(s),d=e.root||document,{query:h}=e;return c.observe(d,{childList:!0,subtree:!0}),h.length&&n(d.querySelectorAll(h)),{drop:e=>{for(let t=0,{length:l}=e;t<l;t++)r.delete(e[t])},flush:()=>{s(c.takeRecords())},observer:c,parse:n}},e}({}).default;

@@ -15,2 +15,6 @@ const elements = element => 'querySelectorAll' in element;

};
const drop = elements => {
for (let i = 0, {length} = elements; i < length; i++)
live.delete(elements[i]);
};
const flush = () => {

@@ -21,2 +25,3 @@ callback(observer.takeRecords());

for (let selectors, element, i = 0, {length} = elements; i < length; i++) {
// guard against repeated elements within nested querySelectorAll results
if (!set.has(element = elements[i])) {

@@ -30,2 +35,3 @@ set.add(element);

selectors = live.get(element);
// guard against selectors that were handled already
if (!selectors.has(q)) {

@@ -38,2 +44,3 @@ selectors.add(q);

}
// guard against elements that never became live
else if (live.has(element)) {

@@ -64,3 +71,3 @@ selectors = live.get(element);

parse(root.querySelectorAll(query));
return {flush, observer, parse};
return {drop, flush, observer, parse};
};

@@ -23,2 +23,8 @@ self.qsaObserver = (function (exports) {

var drop = function drop(elements) {
for (var i = 0, length = elements.length; i < length; i++) {
live["delete"](elements[i]);
}
};
var flush = function flush() {

@@ -32,2 +38,3 @@ callback(observer.takeRecords());

var _loop = function _loop(_selectors, _element, i, length) {
// guard against repeated elements within nested querySelectorAll results
if (!set.has(_element = elements[i])) {

@@ -40,3 +47,3 @@ set.add(_element);

if (!live.has(_element)) live.set(_element, new Set());
_selectors = live.get(_element);
_selectors = live.get(_element); // guard against selectors that were handled already

@@ -50,10 +57,11 @@ if (!_selectors.has(q)) {

}
} else if (live.has(_element)) {
_selectors = live.get(_element);
live["delete"](_element);
} // guard against elements that never became live
else if (live.has(_element)) {
_selectors = live.get(_element);
live["delete"](_element);
_selectors.forEach(function (q) {
options.handle(_element, connected, _selectors[i]);
});
}
_selectors.forEach(function (q) {
options.handle(_element, connected, q);
});
}

@@ -90,2 +98,3 @@ loop(_element.querySelectorAll(query), connected, query, set);

return {
drop: drop,
flush: flush,

@@ -92,0 +101,0 @@ observer: observer,

@@ -1,1 +0,1 @@

self.qsaObserver=function(e){"use strict";var t=function(e){return"querySelectorAll"in e},r=[].filter;return e.default=function(e){var n=new WeakMap,l=function(n){var l=e.query;if(l.length)for(var a=0,c=n.length;a<c;a++)o(r.call(n[a].addedNodes,t),!0,l),o(r.call(n[a].removedNodes,t),!1,l)},o=function t(r,l,o){for(var c,u,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new Set,i=function(i,f,d,h){if(!s.has(f=r[d])){if(s.add(f),l)for(var v,g=a(f),q=0,S=o.length;q<S;q++)g.call(f,v=o[q])&&(n.has(f)||n.set(f,new Set),(i=n.get(f)).has(v)||(i.add(v),e.handle(f,l,v)));else n.has(f)&&(i=n.get(f),n.delete(f),i.forEach((function(t){e.handle(f,l,i[d])})));t(f.querySelectorAll(o),l,o,s)}c=i,u=f},f=0,d=r.length;f<d;f++)i(c,u,f)},a=function(e){return e.matches||e.webkitMatchesSelector||e.msMatchesSelector},c=function(t){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];o(t,r,e.query)},u=new MutationObserver(l),s=e.root||document,i=e.query;return u.observe(s,{childList:!0,subtree:!0}),i.length&&c(s.querySelectorAll(i)),{flush:function(){l(u.takeRecords())},observer:u,parse:c}},e}({}).default;
self.qsaObserver=function(e){"use strict";var t=function(e){return"querySelectorAll"in e},r=[].filter;return e.default=function(e){var n=new WeakMap,l=function(n){var l=e.query;if(l.length)for(var a=0,c=n.length;a<c;a++)o(r.call(n[a].addedNodes,t),!0,l),o(r.call(n[a].removedNodes,t),!1,l)},o=function t(r,l,o){for(var c,u,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new Set,f=function(f,i,d,h){if(!s.has(i=r[d])){if(s.add(i),l)for(var v,g=a(i),q=0,S=o.length;q<S;q++)g.call(i,v=o[q])&&(n.has(i)||n.set(i,new Set),(f=n.get(i)).has(v)||(f.add(v),e.handle(i,l,v)));else n.has(i)&&(f=n.get(i),n.delete(i),f.forEach((function(t){e.handle(i,l,t)})));t(i.querySelectorAll(o),l,o,s)}c=f,u=i},i=0,d=r.length;i<d;i++)f(c,u,i)},a=function(e){return e.matches||e.webkitMatchesSelector||e.msMatchesSelector},c=function(t){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];o(t,r,e.query)},u=new MutationObserver(l),s=e.root||document,f=e.query;return u.observe(s,{childList:!0,subtree:!0}),f.length&&c(s.querySelectorAll(f)),{drop:function(e){for(var t=0,r=e.length;t<r;t++)n.delete(e[t])},flush:function(){l(u.takeRecords())},observer:u,parse:c}},e}({}).default;
{
"name": "qsa-observer",
"version": "1.0.0",
"version": "1.1.0",
"description": "handle elements lifecycle through CSS selectors",

@@ -5,0 +5,0 @@ "main": "./cjs/index.js",

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