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

@asamuzakjp/dom-selector

Package Overview
Dependencies
Maintainers
1
Versions
191
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@asamuzakjp/dom-selector - npm Package Compare versions

Comparing version 4.1.1 to 4.1.2

4

dist/cjs/js/parser.js

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

var E=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var x=(s,t)=>{for(var r in t)E(s,r,{get:t[r],enumerable:!0})},T=(s,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of y(t))!O.call(s,n)&&n!==r&&E(s,n,{get:()=>t[n],enumerable:!(i=S(t,n))||i.enumerable});return s};var m=s=>T(E({},"__esModule",{value:!0}),s);var C={};x(C,{filterSelector:()=>L,generateCSS:()=>w.generate,parseAstName:()=>I,parseSelector:()=>h,preprocess:()=>u,sortAST:()=>A,unescapeSelector:()=>_,walkAST:()=>$});module.exports=m(C);var d=require("css-tree"),e=require("./constant.js"),w=require("css-tree");const _=(s="")=>{if(typeof s=="string"&&s.indexOf("\\",0)>=0){const t=s.split("\\"),r=t.length;for(let i=1;i<r;i++){let n=t[i];if(n===""&&i===r-1)n=e.U_FFFD;else{const c=/^([\da-f]{1,6}\s?)/i.exec(n);if(c){const[,a]=c;let l;try{const o=parseInt("D800",e.HEX),p=parseInt("DFFF",e.HEX),g=parseInt(a,e.HEX);g===0||g>=o&&g<=p?l=e.U_FFFD:l=String.fromCodePoint(g)}catch{l=e.U_FFFD}let f="";n.length>a.length&&(f=n.substring(a.length)),n=`${l}${f}`}else/^[\n\r\f]/.test(n)&&(n="\\"+n)}t[i]=n}s=t.join("")}return s},u=(...s)=>{if(!s.length)throw new TypeError("1 argument required, but only 0 present.");let[t]=s;if(typeof t=="string"){let r=0;for(;r>=0&&(r=t.indexOf("#",r),!(r<0));){const i=t.substring(0,r+1);let n=t.substring(r+1);const c=n.codePointAt(0);if(c===e.BIT_HYPHEN){if(/^\d$/.test(n.substring(1,2)))throw new DOMException(`Invalid selector ${t}`,e.SYNTAX_ERR)}else if(c>e.BIT_FFFF){const a=`\\${c.toString(e.HEX)} `;n.length===e.DUO?n=a:n=`${a}${n.substring(e.DUO)}`}t=`${i}${n}`,r++}t=t.replace(/\f|\r\n?/g,`
`).replace(/[\0\uD800-\uDFFF]|\\$/g,e.U_FFFD)}else if(t==null)t=Object.prototype.toString.call(t).slice(e.TYPE_FROM,e.TYPE_TO).toLowerCase();else if(Array.isArray(t))t=t.join(",");else if(Object.prototype.hasOwnProperty.call(t,"toString"))t=t.toString();else throw new DOMException(`Invalid selector ${t}`,e.SYNTAX_ERR);return t},h=s=>{if(s=u(s),/^$|^\s*>|,\s*$/.test(s))throw new DOMException(`Invalid selector ${s}`,e.SYNTAX_ERR);let t;try{const r=(0,d.parse)(s,{context:"selectorList",parseCustomProperty:!0});t=(0,d.toPlainObject)(r)}catch(r){const i=/(:lang\(\s*("[A-Za-z\d\-*]+")\s*\))/;if(r.message==="Identifier is expected"&&i.test(s)){const[,n,c]=i.exec(s),a=c.replaceAll("*","\\*").replace(/^"/,"").replace(/"$/,""),l=n.replace(c,a);t=h(s.replace(n,l))}else if(r.message==='"]" is expected'&&!s.endsWith("]"))t=h(`${s}]`);else if(r.message==='")" is expected'&&!s.endsWith(")"))t=h(`${s})`);else throw new DOMException(r.message,e.SYNTAX_ERR)}return t},$=(s={})=>{const t=new Set;let r;return(0,d.walk)(s,{enter:n=>{n.type===e.SELECTOR?t.add(n.children):(n.type===e.SELECTOR_PSEUDO_CLASS&&e.REG_LOGICAL_PSEUDO.test(n.name)||n.type===e.SELECTOR_PSEUDO_ELEMENT&&e.REG_SHADOW_PSEUDO.test(n.name))&&(r=!0)}}),r&&(0,d.findAll)(s,(n,c,a)=>{if(a){if(n.type===e.SELECTOR_PSEUDO_CLASS&&e.REG_LOGICAL_PSEUDO.test(n.name)){const l=a.filter(f=>{const{name:o,type:p}=f;return p===e.SELECTOR_PSEUDO_CLASS&&e.REG_LOGICAL_PSEUDO.test(o)});for(const{children:f}of l)for(const{children:o}of f)for(const{children:p}of o)t.has(p)&&t.delete(p)}else if(n.type===e.SELECTOR_PSEUDO_ELEMENT&&e.REG_SHADOW_PSEUDO.test(n.name)){const l=a.filter(f=>{const{name:o,type:p}=f;return p===e.SELECTOR_PSEUDO_ELEMENT&&e.REG_SHADOW_PSEUDO.test(o)});for(const{children:f}of l)for(const{children:o}of f)t.has(o)&&t.delete(o)}}}),[...t]},A=s=>{const t=[...s];if(t.length>1){const r=new Map([[e.SELECTOR_PSEUDO_ELEMENT,e.BIT_01],[e.SELECTOR_ID,e.BIT_02],[e.SELECTOR_CLASS,e.BIT_04],[e.SELECTOR_TYPE,e.BIT_08],[e.SELECTOR_ATTR,e.BIT_16],[e.SELECTOR_PSEUDO_CLASS,e.BIT_32]]);t.sort((i,n)=>{const{type:c}=i,{type:a}=n,l=r.get(c),f=r.get(a);let o;return l===f?o=0:l>f?o=1:o=-1,o})}return t},I=s=>{let t,r;if(s&&typeof s=="string")s.indexOf("|")>-1?[t,r]=s.split("|"):(t="*",r=s);else throw new DOMException(`Invalid selector ${s}`,e.SYNTAX_ERR);return{prefix:t,localName:r}},L=s=>!(!s||typeof s!="string"||/\||::|\[\s*[\w$*=^|~-]+(?:\s+[\w$*=^|~-]+)+\s*\]|\[\s*[\w$*=^|~-]+["'][\w$*=^|~\s-]+['"]+\s+[\w$*=^|~-]+\s*\]/.test(s)||s.includes(":")&&/:(?!(?:first|last|only)-(?:child|of-type)|nth-(?:last-)?(?:child|of-type)\(\s*(?:even|odd|n|[+-]?(?:0|[1-9]\d*)n?|(?:[+-]?(?:0|[1-9]\d*))?n\s*[+-]\s*(?:0|[1-9]\d*))\s*\)|(?:is|not|where)\(\s*(?:\*|[A-Za-z][\w-]*|(?:\*|[A-Za-z][\w-]*)?(?:\[[^\]]+\]|[#.:][\w-]+)+)(?:\s*,\s*(?:\*|[A-Za-z][\w-]*|(?:\*|[A-Za-z][\w-]*)?(?:\[[^\]]+\]|[#.:][\w-]+)+))*\s*\))/.test(s));0&&(module.exports={filterSelector,generateCSS,parseAstName,parseSelector,preprocess,sortAST,unescapeSelector,walkAST});
var g=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var O=(s,t)=>{for(var r in t)g(s,r,{get:t[r],enumerable:!0})},x=(s,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of A(t))!y.call(s,n)&&n!==r&&g(s,n,{get:()=>t[n],enumerable:!(i=S(t,n))||i.enumerable});return s};var T=s=>x(g({},"__esModule",{value:!0}),s);var C={};O(C,{filterSelector:()=>L,generateCSS:()=>u.generate,parseAstName:()=>I,parseSelector:()=>h,preprocess:()=>E,sortAST:()=>$,unescapeSelector:()=>m,walkAST:()=>_});module.exports=T(C);var w=require("css-tree"),e=require("./constant.js"),u=require("css-tree");const m=(s="")=>{if(typeof s=="string"&&s.indexOf("\\",0)>=0){const t=s.split("\\"),r=t.length;for(let i=1;i<r;i++){let n=t[i];if(n===""&&i===r-1)n=e.U_FFFD;else{const c=/^([\da-f]{1,6}\s?)/i.exec(n);if(c){const[,a]=c;let l;try{const o=parseInt("D800",e.HEX),p=parseInt("DFFF",e.HEX),d=parseInt(a,e.HEX);d===0||d>=o&&d<=p?l=e.U_FFFD:l=String.fromCodePoint(d)}catch{l=e.U_FFFD}let f="";n.length>a.length&&(f=n.substring(a.length)),n=`${l}${f}`}else/^[\n\r\f]/.test(n)&&(n="\\"+n)}t[i]=n}s=t.join("")}return s},E=(...s)=>{if(!s.length)throw new TypeError("1 argument required, but only 0 present.");let[t]=s;if(typeof t=="string"){let r=0;for(;r>=0&&(r=t.indexOf("#",r),!(r<0));){const i=t.substring(0,r+1);let n=t.substring(r+1);const c=n.codePointAt(0);if(c===e.BIT_HYPHEN){if(/^\d$/.test(n.substring(1,2)))throw new DOMException(`Invalid selector ${t}`,e.SYNTAX_ERR)}else if(c>e.BIT_FFFF){const a=`\\${c.toString(e.HEX)} `;n.length===e.DUO?n=a:n=`${a}${n.substring(e.DUO)}`}t=`${i}${n}`,r++}t=t.replace(/\f|\r\n?/g,`
`).replace(/[\0\uD800-\uDFFF]|\\$/g,e.U_FFFD)}else if(t==null)t=Object.prototype.toString.call(t).slice(e.TYPE_FROM,e.TYPE_TO).toLowerCase();else if(Array.isArray(t))t=t.join(",");else if(Object.prototype.hasOwnProperty.call(t,"toString"))t=t.toString();else throw new DOMException(`Invalid selector ${t}`,e.SYNTAX_ERR);return t},h=s=>{if(s=E(s),/^$|^\s*>|,\s*$/.test(s))throw new DOMException(`Invalid selector ${s}`,e.SYNTAX_ERR);let t;try{const r=(0,w.parse)(s,{context:"selectorList",parseCustomProperty:!0});t=(0,w.toPlainObject)(r)}catch(r){const i=/(:lang\(\s*("[A-Za-z\d\-*]+")\s*\))/;if(r.message==="Identifier is expected"&&i.test(s)){const[,n,c]=i.exec(s),a=c.replaceAll("*","\\*").replace(/^"/,"").replace(/"$/,""),l=n.replace(c,a);t=h(s.replace(n,l))}else if(r.message==='"]" is expected'&&!s.endsWith("]"))t=h(`${s}]`);else if(r.message==='")" is expected'&&!s.endsWith(")"))t=h(`${s})`);else throw new DOMException(r.message,e.SYNTAX_ERR)}return t},_=(s={})=>{const t=new Set;let r;return(0,w.walk)(s,{enter:n=>{n.type===e.SELECTOR?t.add(n.children):(n.type===e.SELECTOR_PSEUDO_CLASS&&e.REG_LOGICAL_PSEUDO.test(n.name)||n.type===e.SELECTOR_PSEUDO_ELEMENT&&e.REG_SHADOW_PSEUDO.test(n.name))&&(r=!0)}}),r&&(0,w.findAll)(s,(n,c,a)=>{if(a){if(n.type===e.SELECTOR_PSEUDO_CLASS&&e.REG_LOGICAL_PSEUDO.test(n.name)){const l=a.filter(f=>{const{name:o,type:p}=f;return p===e.SELECTOR_PSEUDO_CLASS&&e.REG_LOGICAL_PSEUDO.test(o)});for(const{children:f}of l)for(const{children:o}of f)for(const{children:p}of o)t.has(p)&&t.delete(p)}else if(n.type===e.SELECTOR_PSEUDO_ELEMENT&&e.REG_SHADOW_PSEUDO.test(n.name)){const l=a.filter(f=>{const{name:o,type:p}=f;return p===e.SELECTOR_PSEUDO_ELEMENT&&e.REG_SHADOW_PSEUDO.test(o)});for(const{children:f}of l)for(const{children:o}of f)t.has(o)&&t.delete(o)}}}),[...t]},$=s=>{const t=[...s];if(t.length>1){const r=new Map([[e.SELECTOR_PSEUDO_ELEMENT,e.BIT_01],[e.SELECTOR_ID,e.BIT_02],[e.SELECTOR_CLASS,e.BIT_04],[e.SELECTOR_TYPE,e.BIT_08],[e.SELECTOR_ATTR,e.BIT_16],[e.SELECTOR_PSEUDO_CLASS,e.BIT_32]]);t.sort((i,n)=>{const{type:c}=i,{type:a}=n,l=r.get(c),f=r.get(a);let o;return l===f?o=0:l>f?o=1:o=-1,o})}return t},I=s=>{let t,r;if(s&&typeof s=="string")s.indexOf("|")>-1?[t,r]=s.split("|"):(t="*",r=s);else throw new DOMException(`Invalid selector ${s}`,e.SYNTAX_ERR);return{prefix:t,localName:r}},L=s=>!(!s||typeof s!="string"||/\||::|\[\s*[\w$*=^|~-]+(?:\s+[\w$*=^|~-]+)+\s*\]|\[\s*[\w$*=^|~-]+["'][\w$*=^|~\s-]+['"]+\s+[\w$*=^|~-]+\s*\]/.test(s)||s.includes(":")&&/:(?!(?:first|last|only)-(?:child|of-type)|nth-(?:last-)?(?:child|of-type)\(\s*(?:even|odd|n|[+-]?(?:0|[1-9]\d*)n?|(?:[+-]?(?:0|[1-9]\d*))?n\s*[+-]\s*(?:0|[1-9]\d*))\s*\)|(?:is|not|where)\(\s*(?:\*|[A-Za-z][\w-]*|(?:\*|[A-Za-z][\w-]*)?(?:\[[^\]]+\]|[#.:][\w-]+|:(?:is|not|where)\(\s*(?:\*|[A-Za-z][\w-]*|(?:\*|[A-Za-z][\w-]*)?(?:\[[^\]]+\]|[#.:][\w-]+)+)(?:\s*,\s*(?:\*|[A-Za-z][\w-]*|(?:\*|[A-Za-z][\w-]*)?(?:\[[^\]]+\]|[#.:][\w-]+)+))*\s*\))+)(?:\s*,\s*(?:\*|[A-Za-z][\w-]*|(?:\*|[A-Za-z][\w-]*)?(?:\[[^\]]+\]|[#.:][\w-]+|:(?:is|not|where)\(\s*(?:\*|[A-Za-z][\w-]*|(?:\*|[A-Za-z][\w-]*)?(?:\[[^\]]+\]|[#.:][\w-]+)+)(?:\s*,\s*(?:\*|[A-Za-z][\w-]*|(?:\*|[A-Za-z][\w-]*)?(?:\[[^\]]+\]|[#.:][\w-]+)+))*\s*\))+))*\s*\))/.test(s));0&&(module.exports={filterSelector,generateCSS,parseAstName,parseSelector,preprocess,sortAST,unescapeSelector,walkAST});
//# sourceMappingURL=parser.js.map

@@ -63,3 +63,3 @@ {

},
"version": "4.1.1"
"version": "4.1.2"
}

@@ -246,7 +246,8 @@ # DOM Selector

|:-----------|:-----------|:-----------|:-----------|:-----------|:-----------|
|simple selector:<br>`matches('.content')`|1,069,929 ops/sec ±0.34%|7,126 ops/sec ±0.88%|8,555 ops/sec ±0.70%|946,961 ops/sec ±0.15%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
|compound selector:<br>`matches('p.content[id]:is(:last-child, :only-child)')`|601,355 ops/sec ±0.33%|7,016 ops/sec ±1.12%|8,644 ops/sec ±0.51%|508,012 ops/sec ±0.24%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
|compound selector:<br>`matches('p.content[id]:is(:invalid-nth-child, :only-child)')`|N/A|7,082 ops/sec ±0.21%|N/A|153,958 ops/sec ±0.96%|patched-jsdom is the fastest.|
|complex selector:<br>`matches('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|167,052 ops/sec ±0.19%|N/A|7,700 ops/sec ±0.45%|146,612 ops/sec ±0.22%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
|complex selector:<br>`matches('.box:first-child ~ .box:nth-of-type(4n+1) + .box .block.inner:has(> .content)')`|N/A|N/A|7,573 ops/sec ±0.47%|44,413 ops/sec ±0.66%|patched-jsdom is the fastest.|
|simple selector:<br>`matches('.content')`|1,000,095 ops/sec ±0.29%|6,105 ops/sec ±0.45%|8,636 ops/sec ±0.36%|949,741 ops/sec ±0.21%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
|compound selector:<br>`matches('p.content[id]:is(:last-child, :only-child)')`|592,559 ops/sec ±1.72%|5,932 ops/sec ±0.48%|8,724 ops/sec ±0.67%|517,958 ops/sec ±0.28%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
|compound selector:<br>`matches('p.content[id]:is(:invalid-nth-child, :only-child)')`|N/A|5,893 ops/sec ±0.35%|N/A|157,436 ops/sec ±0.22%|patched-jsdom is the fastest.|
|compound selector:<br>`matches('p.content[id]:not(:is(.foo, .bar))')`|481,007 ops/sec ±0.24%|N/A|8,232 ops/sec ±0.26%|405,841 ops/sec ±1.50%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
|complex selector:<br>`matches('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|162,394 ops/sec ±1.46%|N/A|7,686 ops/sec ±0.76%|143,901 ops/sec ±1.34%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
|complex selector:<br>`matches('.box:first-child ~ .box:nth-of-type(4n+1) + .box .block.inner:has(> .content)')`|N/A|N/A|7,645 ops/sec ±0.91%|46,398 ops/sec ±1.03%|patched-jsdom is the fastest.|

@@ -257,6 +258,6 @@ ### closest()

|:-----------|:-----------|:-----------|:-----------|:-----------|:-----------|
|simple selector:<br>`closest('.container')`|387,330 ops/sec ±1.52%|7,076 ops/sec ±0.91%|8,491 ops/sec ±0.53%|375,594 ops/sec ±1.31%|jsdom is the fastest and 1.0 times faster than patched-jsdom.|
|compound selector:<br>`closest('div.container[id]:not(.box)')`|180,638 ops/sec ±1.58%|6,492 ops/sec ±1.00%|8,198 ops/sec ±0.71%|173,121 ops/sec ±0.10%|jsdom is the fastest and 1.0 times faster than patched-jsdom.|
|complex selector:<br>`closest('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|152,683 ops/sec ±0.08%|N/A|7,548 ops/sec ±0.85%|137,912 ops/sec ±1.40%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
|complex selector:<br>`closest('.box:first-child ~ .box:nth-of-type(4n+1) + .box .block.inner:has(> .content)')`|N/A|N/A|7,469 ops/sec ±0.65%|30,497 ops/sec ±0.84%|patched-jsdom is the fastest.|
|simple selector:<br>`closest('.container')`|384,943 ops/sec ±0.17%|6,050 ops/sec ±0.26%|8,544 ops/sec ±0.49%|373,062 ops/sec ±2.06%|jsdom is the fastest and 1.0 times faster than patched-jsdom.|
|compound selector:<br>`closest('div.container[id]:not(.foo, .box)')`|136,836 ops/sec ±1.49%|N/A|8,201 ops/sec ±0.65%|133,472 ops/sec ±1.39%|jsdom is the fastest and 1.0 times faster than patched-jsdom.|
|complex selector:<br>`closest('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|151,300 ops/sec ±1.42%|N/A|7,769 ops/sec ±0.48%|136,348 ops/sec ±1.36%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
|complex selector:<br>`closest('.box:first-child ~ .box:nth-of-type(4n+1) + .box .block.inner:has(> .content)')`|N/A|N/A|7,648 ops/sec ±0.60%|32,514 ops/sec ±0.85%|patched-jsdom is the fastest.|

@@ -267,6 +268,6 @@ ### querySelector()

|:-----------|:-----------|:-----------|:-----------|:-----------|:-----------|
|simple selector:<br>`querySelector('.content')`|35,135 ops/sec ±1.63%|8,473 ops/sec ±0.72%|9,958 ops/sec ±0.90%|28,201 ops/sec ±2.12%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
|compound selector:<br>`querySelector('p.content[id]:is(:last-child, :only-child)')`|10,717 ops/sec ±1.39%|8,378 ops/sec ±0.70%|9,366 ops/sec ±0.27%|9,348 ops/sec ±1.76%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
|complex selector:<br>`querySelector('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|233 ops/sec ±0.71%|N/A|1,298 ops/sec ±0.40%|689 ops/sec ±1.14%|linkedom is the fastest and 1.9 times faster than patched-jsdom. patched-jsdom is 3.0 times faster than jsdom.|
|complex selector:<br>`querySelector('.box:first-child ~ .box:nth-of-type(4n+1) + .box .block.inner:has(> .content)')`|N/A|N/A|1,569 ops/sec ±0.29%|464 ops/sec ±1.73%|linkedom is the fastest and 3.4 times faster than patched-jsdom.|
|simple selector:<br>`querySelector('.content')`|36,453 ops/sec ±1.64%|7,377 ops/sec ±0.82%|9,762 ops/sec ±0.43%|30,278 ops/sec ±1.31%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
|compound selector:<br>`querySelector('p.content[id]:is(:last-child, :only-child)')`|10,518 ops/sec ±1.26%|7,286 ops/sec ±0.67%|9,400 ops/sec ±0.54%| 9,657 ops/sec ±1.35%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
|complex selector:<br>`querySelector('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|230 ops/sec ±1.38%|N/A|1,309 ops/sec ±1.39%|732 ops/sec ±2.31%|linkedom is the fastest and 1.8 times faster than patched-jsdom. patched-jsdom is 3.2 times faster than jsdom.|
|complex selector:<br>`querySelector('.box:first-child ~ .box:nth-of-type(4n+1) + .box .block.inner:has(> .content)')`|N/A|N/A|1,626 ops/sec ±0.28%|493 ops/sec ±2.35%|linkedom is the fastest and 3.3 times faster than patched-jsdom.|

@@ -277,6 +278,6 @@ ### querySelectorAll()

|:-----------|:-----------|:-----------|:-----------|:-----------|:-----------|
|simple selector:<br>`querySelectorAll('.content')`|2,839 ops/sec ±1.01%|822 ops/sec ±1.68%|1,215 ops/sec ±1.37%|3,398 ops/sec ±0.33%|patched-jsdom is the fastest. patched-jsdom is 1.2 times faster than jsdom.|
|compound selector:<br>`querySelectorAll('p.content[id]:is(:last-child, :only-child)')`|1,003 ops/sec ±1.20%|987 ops/sec ±1.66%|1,195 ops/sec ±1.07%|1,059 ops/sec ±1.09%|linkedom is the fastest and 1.1 times faster than patched-jsdom. patched-jsdom is 1.1 times faster than jsdom.|
|complex selector:<br>`querySelectorAll('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|230 ops/sec ±0.84%|N/A|426 ops/sec ±0.18%|781 ops/sec ±1.34%|patched-jsdom is the fastest. patched-jsdom is 3.4 times faster than jsdom.|
|complex selector:<br>`querySelectorAll('.box:first-child ~ .box:nth-of-type(4n+1) + .box .block.inner:has(> .content)')`|N/A|N/A|463 ops/sec ±0.25%|492 ops/sec ±2.09%|patched-jsdom is the fastest.|
|simple selector:<br>`querySelectorAll('.content')`|3,194 ops/sec ±1.32%|794 ops/sec ±1.69%|1,213 ops/sec ±0.20%|3,526 ops/sec ±0.24%|patched-jsdom is the fastest. patched-jsdom is 1.1 times faster than jsdom.|
|compound selector:<br>`querySelectorAll('p.content[id]:is(:last-child, :only-child)')`|1,056 ops/sec ±0.21%|946 ops/sec ±1.32%|1,166 ops/sec ±1.19%|1,063 ops/sec ±1.09%|linkedom is the fastest and 1.1 times faster than patched-jsdom. patched-jsdom is 1.0 times faster than jsdom.|
|complex selector:<br>`querySelectorAll('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|233 ops/sec ±1.24%|N/A|428 ops/sec ±1.25%|819 ops/sec ±1.43%|patched-jsdom is the fastest. patched-jsdom is 3.5 times faster than jsdom.|
|complex selector:<br>`querySelectorAll('.box:first-child ~ .box:nth-of-type(4n+1) + .box .block.inner:has(> .content)')`|N/A|N/A|460 ops/sec ±0.20%|534 ops/sec ±1.83%|patched-jsdom is the fastest.|

@@ -283,0 +284,0 @@

@@ -310,4 +310,6 @@ /**

// subclass: attr, class, id, pseudo-class
// \[[^\]]+\]|[#.:][\w-]+|:${logical}
// subclass w/o logical:
// \[[^\]]+\]|[#.:][\w-]+
if (/:(?!(?:first|last|only)-(?:child|of-type)|nth-(?:last-)?(?:child|of-type)\(\s*(?:even|odd|n|[+-]?(?:0|[1-9]\d*)n?|(?:[+-]?(?:0|[1-9]\d*))?n\s*[+-]\s*(?:0|[1-9]\d*))\s*\)|(?:is|not|where)\(\s*(?:\*|[A-Za-z][\w-]*|(?:\*|[A-Za-z][\w-]*)?(?:\[[^\]]+\]|[#.:][\w-]+)+)(?:\s*,\s*(?:\*|[A-Za-z][\w-]*|(?:\*|[A-Za-z][\w-]*)?(?:\[[^\]]+\]|[#.:][\w-]+)+))*\s*\))/.test(selector)) {
if (/:(?!(?:first|last|only)-(?:child|of-type)|nth-(?:last-)?(?:child|of-type)\(\s*(?:even|odd|n|[+-]?(?:0|[1-9]\d*)n?|(?:[+-]?(?:0|[1-9]\d*))?n\s*[+-]\s*(?:0|[1-9]\d*))\s*\)|(?:is|not|where)\(\s*(?:\*|[A-Za-z][\w-]*|(?:\*|[A-Za-z][\w-]*)?(?:\[[^\]]+\]|[#.:][\w-]+|:(?:is|not|where)\(\s*(?:\*|[A-Za-z][\w-]*|(?:\*|[A-Za-z][\w-]*)?(?:\[[^\]]+\]|[#.:][\w-]+)+)(?:\s*,\s*(?:\*|[A-Za-z][\w-]*|(?:\*|[A-Za-z][\w-]*)?(?:\[[^\]]+\]|[#.:][\w-]+)+))*\s*\))+)(?:\s*,\s*(?:\*|[A-Za-z][\w-]*|(?:\*|[A-Za-z][\w-]*)?(?:\[[^\]]+\]|[#.:][\w-]+|:(?:is|not|where)\(\s*(?:\*|[A-Za-z][\w-]*|(?:\*|[A-Za-z][\w-]*)?(?:\[[^\]]+\]|[#.:][\w-]+)+)(?:\s*,\s*(?:\*|[A-Za-z][\w-]*|(?:\*|[A-Za-z][\w-]*)?(?:\[[^\]]+\]|[#.:][\w-]+)+))*\s*\))+))*\s*\))/.test(selector)) {
return false;

@@ -314,0 +316,0 @@ }

Sorry, the diff of this file is not supported yet

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