New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@asamuzakjp/dom-selector

Package Overview
Dependencies
Maintainers
1
Versions
193
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 0.18.1 to 0.19.1

4

package.json

@@ -19,6 +19,6 @@ {

"main": "src/index.js",
"type": "module",
"types": "types/index.d.ts",
"dependencies": {
"css-tree": "^2.3.1",
"domexception": "^4.0.0",
"is-potential-custom-element-name": "^1.0.1"

@@ -50,3 +50,3 @@ },

},
"version": "0.18.1"
"version": "0.19.1"
}

@@ -23,5 +23,5 @@ # DOM Selector

```javascript
const {
import {
matches, closest, querySelector, querySelectorAll
} = require('@asamuzakjp/dom-selector');
} from '@asamuzakjp/dom-selector';
```

@@ -42,3 +42,3 @@

Returns **[boolean][61]** result
Returns **[boolean][61]** `true` if matched `false` otherwise

@@ -84,2 +84,3 @@

- `opt` **[object][60]?** options
- `opt.sort` **[boolean][61]?** sort matched nodes
- `opt.warn` **[boolean][61]?** console warn e.g. unsupported pseudo-class

@@ -86,0 +87,0 @@

@@ -7,65 +7,50 @@ /*!

*/
'use strict';
/* import */
const { Matcher } = require('./js/matcher.js');
import { Matcher } from './js/matcher.js';
/**
* matches - Element.matches()
* matches
* @param {string} selector - CSS selector
* @param {object} node - Element node
* @param {object} [opt] - options
* @param {object} [opt.warn] - console warn e.g. unsupported pseudo-class
* @returns {boolean} - result
* @param {boolean} [opt.warn] - console warn e.g. unsupported pseudo-class
* @returns {boolean} - `true` if matched `false` otherwise
*/
const matches = (selector, node, opt) => {
const matcher = new Matcher(selector, node, opt);
return matcher.matches();
};
export const matches = (selector, node, opt) =>
new Matcher(selector, node, opt).matches();
/**
* closest - Element.closest()
* closest
* @param {string} selector - CSS selector
* @param {object} node - Element node
* @param {object} [opt] - options
* @param {object} [opt.warn] - console warn e.g. unsupported pseudo-class
* @param {boolean} [opt.warn] - console warn e.g. unsupported pseudo-class
* @returns {?object} - matched node
*/
const closest = (selector, node, opt) => {
const matcher = new Matcher(selector, node, opt);
return matcher.closest();
};
export const closest = (selector, node, opt) =>
new Matcher(selector, node, opt).closest();
/**
* querySelector - Document.querySelector(), Element.querySelector()
* querySelector
* @param {string} selector - CSS selector
* @param {object} refPoint - Document or Element node
* @param {object} refPoint - Document, DocumentFragment or Element node
* @param {object} [opt] - options
* @param {object} [opt.warn] - console warn e.g. unsupported pseudo-class
* @param {boolean} [opt.warn] - console warn e.g. unsupported pseudo-class
* @returns {?object} - matched node
*/
const querySelector = (selector, refPoint, opt) => {
const matcher = new Matcher(selector, refPoint, opt);
return matcher.querySelector();
};
export const querySelector = (selector, refPoint, opt) =>
new Matcher(selector, refPoint, opt).querySelector();
/**
* querySelectorAll - Document.querySelectorAll(), Element.querySelectorAll()
* querySelectorAll
* NOTE: returns Array, not NodeList
* @param {string} selector - CSS selector
* @param {object} refPoint - Document or Element node
* @param {object} refPoint - Document, DocumentFragment or Element node
* @param {object} [opt] - options
* @param {object} [opt.warn] - console warn e.g. unsupported pseudo-class
* @param {boolean} [opt.sort] - sort matched nodes
* @param {boolean} [opt.warn] - console warn e.g. unsupported pseudo-class
* @returns {Array.<object|undefined>} - array of matched nodes
*/
const querySelectorAll = (selector, refPoint, opt) => {
const matcher = new Matcher(selector, refPoint, opt);
return matcher.querySelectorAll();
};
module.exports = {
closest,
matches,
querySelector,
querySelectorAll
};
export const querySelectorAll = (selector, refPoint, opt) =>
new Matcher(selector, refPoint, opt).querySelectorAll();
/**
* constant.js
*/
'use strict';
const AN_PLUS_B = 'AnPlusB';
const ATTRIBUTE_SELECTOR = 'AttributeSelector';
const CLASS_SELECTOR = 'ClassSelector';
const COMBINATOR = 'Combinator';
const ID_SELECTOR = 'IdSelector';
const IDENTIFIER = 'Identifier';
const NTH = 'Nth';
const PSEUDO_CLASS_SELECTOR = 'PseudoClassSelector';
const PSEUDO_ELEMENT_SELECTOR = 'PseudoElementSelector';
const RAW = 'Raw';
const SELECTOR = 'Selector';
const SELECTOR_LIST = 'SelectorList';
const STRING = 'String';
const TYPE_SELECTOR = 'TypeSelector';
module.exports = {
AN_PLUS_B,
ATTRIBUTE_SELECTOR,
CLASS_SELECTOR,
COMBINATOR,
ID_SELECTOR,
IDENTIFIER,
NTH,
PSEUDO_CLASS_SELECTOR,
PSEUDO_ELEMENT_SELECTOR,
RAW,
SELECTOR,
SELECTOR_LIST,
STRING,
TYPE_SELECTOR
};
export const AN_PLUS_B = 'AnPlusB';
export const ATTRIBUTE_SELECTOR = 'AttributeSelector';
export const CLASS_SELECTOR = 'ClassSelector';
export const COMBINATOR = 'Combinator';
export const ID_SELECTOR = 'IdSelector';
export const IDENTIFIER = 'Identifier';
export const NTH = 'Nth';
export const PSEUDO_CLASS_SELECTOR = 'PseudoClassSelector';
export const PSEUDO_ELEMENT_SELECTOR = 'PseudoElementSelector';
export const RAW = 'Raw';
export const SELECTOR = 'Selector';
export const SELECTOR_LIST = 'SelectorList';
export const STRING = 'String';
export const TYPE_SELECTOR = 'TypeSelector';
/**
* parser.js
*/
'use strict';
/* import */
const { generate, findAll, parse, toPlainObject, walk } = require('css-tree');
const DOMException = require('./domexception.js');
import { findAll, parse, toPlainObject, walk } from 'css-tree';
/* constants */
const { PSEUDO_CLASS_SELECTOR, SELECTOR } = require('./constant.js');
import { PSEUDO_CLASS_SELECTOR, SELECTOR } from './constant.js';
const CODE_POINT_UNIT = parseInt('10000', 16);

@@ -27,3 +25,3 @@ const HEX = 16;

*/
const preprocess = (...args) => {
export const preprocess = (...args) => {
if (!args.length) {

@@ -70,3 +68,3 @@ throw new TypeError('1 argument required, but only 0 present');

*/
const parseSelector = selector => {
export const parseSelector = selector => {
selector = preprocess(selector);

@@ -101,3 +99,3 @@ // invalid selectors

*/
const walkAST = (ast = {}) => {
export const walkAST = (ast = {}) => {
const branches = new Set();

@@ -145,7 +143,2 @@ let hasPseudoFunc;

/* export */
module.exports = {
generateCSS: generate,
parseSelector,
preprocess,
walkAST
};
export { generate as generateCSS } from 'css-tree';

Sorry, the diff of this file is too big to display

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