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 0.0.0 to 0.0.1

README.md

35

cjs/index.js

@@ -5,17 +5,9 @@ 'use strict';

module.exports = ({cache, query, root, setup, update}) => {
const matches = element => {
for (let
method = (
element.matches ||
element.webkitMatchesSelector ||
element.msMatchesSelector
),
i = 0, {length} = query; i < length; i++
) {
if (method.call(element, query[i]))
return true;
}
return false;
};
module.exports = (options) => {
const {cache, query, root} = options;
const matches = element => (
element.matches ||
element.webkitMatchesSelector ||
element.msMatchesSelector
);
const parse = (elements, connected, set) => {

@@ -26,4 +18,4 @@ for (let element, i = 0, {length} = elements; i < length; i++) {

if (cache.has(element))
update(element, connected);
else if (connected && matches(element))
options.update(element, connected);
else if (connected)
setup(element);

@@ -34,2 +26,8 @@ parse(element.querySelectorAll(query), connected, set);

};
const setup = element => {
for (let m = matches(element), i = 0, {length} = query; i < length; i++) {
if (m.call(element, query[i]))
options.setup(element, query[i]);
}
};
const observer = new MutationObserver(records => {

@@ -45,3 +43,6 @@ if (query.length) {

observer.observe(root || document, {childList: true, subtree: true});
if (query.length)
parse((root || document).querySelectorAll(query), true, new Set);
return {
matches,
observer,

@@ -48,0 +49,0 @@ parse(elements, connected = true) {

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

self.qsaObserver=function(e){"use strict";const{filter:t}=[],r=e=>"querySelectorAll"in e;return e.default=({cache:e,query:l,root:s,setup:n,update:o})=>{const c=e=>{for(let t=e.matches||e.webkitMatchesSelector||e.msMatchesSelector,r=0,{length:s}=l;r<s;r++)if(t.call(e,l[r]))return!0;return!1},a=(t,r,s)=>{for(let u,d=0,{length:h}=t;d<h;d++)s.has(u=t[d])||(s.add(u),e.has(u)?o(u,r):r&&c(u)&&n(u),a(u.querySelectorAll(l),r,s))},u=new MutationObserver(e=>{if(l.length)for(let l=0,{length:s}=e;l<s;l++){const{addedNodes:s,removedNodes:n}=e[l];a(t.call(s,r),!0,new Set),a(t.call(n,r),!1,new Set)}});return u.observe(s||document,{childList:!0,subtree:!0}),{observer:u,parse(e,t=!0){a(e,t,new Set)}}},e}({}).default;
self.qsaObserver=function(e){"use strict";const{filter:t}=[],r=e=>"querySelectorAll"in e;return e.default=e=>{const{cache:l,query:s,root:c}=e,o=e=>e.matches||e.webkitMatchesSelector||e.msMatchesSelector,n=(t,r,c)=>{for(let o,u=0,{length:d}=t;u<d;u++)c.has(o=t[u])||(c.add(o),l.has(o)?e.update(o,r):r&&a(o),n(o.querySelectorAll(s),r,c))},a=t=>{for(let r=o(t),l=0,{length:c}=s;l<c;l++)r.call(t,s[l])&&e.setup(t,s[l])},u=new MutationObserver(e=>{if(s.length)for(let l=0,{length:s}=e;l<s;l++){const{addedNodes:s,removedNodes:c}=e[l];n(t.call(s,r),!0,new Set),n(t.call(c,r),!1,new Set)}});return u.observe(c||document,{childList:!0,subtree:!0}),s.length&&n((c||document).querySelectorAll(s),!0,new Set),{matches:o,observer:u,parse(e,t=!0){n(e,t,new Set)}}},e}({}).default;
const {filter} = [];
const elements = element => 'querySelectorAll' in element;
export default ({cache, query, root, setup, update}) => {
const matches = element => {
for (let
method = (
element.matches ||
element.webkitMatchesSelector ||
element.msMatchesSelector
),
i = 0, {length} = query; i < length; i++
) {
if (method.call(element, query[i]))
return true;
}
return false;
};
export default (options) => {
const {cache, query, root} = options;
const matches = element => (
element.matches ||
element.webkitMatchesSelector ||
element.msMatchesSelector
);
const parse = (elements, connected, set) => {

@@ -24,4 +16,4 @@ for (let element, i = 0, {length} = elements; i < length; i++) {

if (cache.has(element))
update(element, connected);
else if (connected && matches(element))
options.update(element, connected);
else if (connected)
setup(element);

@@ -32,2 +24,8 @@ parse(element.querySelectorAll(query), connected, set);

};
const setup = element => {
for (let m = matches(element), i = 0, {length} = query; i < length; i++) {
if (m.call(element, query[i]))
options.setup(element, query[i]);
}
};
const observer = new MutationObserver(records => {

@@ -43,3 +41,6 @@ if (query.length) {

observer.observe(root || document, {childList: true, subtree: true});
if (query.length)
parse((root || document).querySelectorAll(query), true, new Set);
return {
matches,
observer,

@@ -46,0 +47,0 @@ parse(elements, connected = true) {

@@ -10,15 +10,9 @@ self.qsaObserver = (function (exports) {

var index = (function (_ref) {
var cache = _ref.cache,
query = _ref.query,
root = _ref.root,
setup = _ref.setup,
update = _ref.update;
var index = (function (options) {
var cache = options.cache,
query = options.query,
root = options.root;
var matches = function matches(element) {
for (var method = element.matches || element.webkitMatchesSelector || element.msMatchesSelector, i = 0, length = query.length; i < length; i++) {
if (method.call(element, query[i])) return true;
}
return false;
return element.matches || element.webkitMatchesSelector || element.msMatchesSelector;
};

@@ -30,3 +24,3 @@

set.add(element);
if (cache.has(element)) update(element, connected);else if (connected && matches(element)) setup(element);
if (cache.has(element)) options.update(element, connected);else if (connected) setup(element);

@@ -38,2 +32,8 @@ _parse(element.querySelectorAll(query), connected, set);

var setup = function setup(element) {
for (var m = matches(element), i = 0, length = query.length; i < length; i++) {
if (m.call(element, query[i])) options.setup(element, query[i]);
}
};
var observer = new MutationObserver(function (records) {

@@ -56,3 +56,5 @@ if (query.length) {

});
if (query.length) _parse((root || document).querySelectorAll(query), true, new Set());
return {
matches: matches,
observer: observer,

@@ -59,0 +61,0 @@ parse: function parse(elements) {

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

self.qsaObserver=function(e){"use strict";var r=[].filter,t=function(e){return"querySelectorAll"in e};return e.default=function(e){var n=e.cache,o=e.query,a=e.root,l=e.setup,c=e.update,u=function(e){for(var r=e.matches||e.webkitMatchesSelector||e.msMatchesSelector,t=0,n=o.length;t<n;t++)if(r.call(e,o[t]))return!0;return!1},s=function(e,r,t){for(var a,i=0,f=e.length;i<f;i++)t.has(a=e[i])||(t.add(a),n.has(a)?c(a,r):r&&u(a)&&l(a),s(a.querySelectorAll(o),r,t))},i=new MutationObserver((function(e){if(o.length)for(var n=0,a=e.length;n<a;n++){var l=e[n],c=l.addedNodes,u=l.removedNodes;s(r.call(c,t),!0,new Set),s(r.call(u,t),!1,new Set)}}));return i.observe(a||document,{childList:!0,subtree:!0}),{observer:i,parse:function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];s(e,r,new Set)}}},e}({}).default;
self.qsaObserver=function(e){"use strict";var t=[].filter,r=function(e){return"querySelectorAll"in e};return e.default=function(e){var n=e.cache,l=e.query,o=e.root,c=function(e){return e.matches||e.webkitMatchesSelector||e.msMatchesSelector},a=function(t,r,o){for(var c,s=0,i=t.length;s<i;s++)o.has(c=t[s])||(o.add(c),n.has(c)?e.update(c,r):r&&u(c),a(c.querySelectorAll(l),r,o))},u=function(t){for(var r=c(t),n=0,o=l.length;n<o;n++)r.call(t,l[n])&&e.setup(t,l[n])},s=new MutationObserver((function(e){if(l.length)for(var n=0,o=e.length;n<o;n++){var c=e[n],u=c.addedNodes,s=c.removedNodes;a(t.call(u,r),!0,new Set),a(t.call(s,r),!1,new Set)}}));return s.observe(o||document,{childList:!0,subtree:!0}),l.length&&a((o||document).querySelectorAll(l),!0,new Set),{matches:c,observer:s,parse:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];a(e,t,new Set)}}},e}({}).default;
{
"name": "qsa-observer",
"version": "0.0.0",
"version": "0.0.1",
"description": "",
"main": "./cjs/index.js",
"scripts": {
"build": "npm run cjs && npm run rollup:es && npm run rollup:babel && npm run min && npm run fix:default && npm run test",
"build": "npm run cjs && npm run rollup:es && npm run rollup:babel && npm run min && npm run fix:default && npm run size",
"cjs": "ascjs --no-default esm cjs",

@@ -12,3 +12,4 @@ "rollup:es": "rollup --config rollup/es.config.js && sed -i.bck 's/^var /self./' es.js && rm -rf es.js.bck",

"min": "terser index.js --comments='/^!/' -c -m -o min.js",
"fix:default": "sed -i 's/({})/({}).default/' index.js && sed -i 's/({})/({}).default/' es.js && sed -i 's/({})/({}).default/' min.js"
"fix:default": "sed -i 's/({})/({}).default/' index.js && sed -i 's/({})/({}).default/' es.js && sed -i 's/({})/({}).default/' min.js",
"size": "cat min.js | gzip -9 | wc -c && cat min.js | brotli | wc -c && cat es.js | gzip -9 | wc -c && cat es.js | brotli | wc -c"
},

@@ -35,2 +36,2 @@ "keywords": [],

"unpkg": "min.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