@markuplint/selector
Advanced tools
Comparing version 3.0.0-alpha.6 to 3.0.0-alpha.27
export declare class InvalidSelectorError extends Error { | ||
name: string; | ||
name: string; | ||
} |
import type { Specificity, RegexSelector } from './types'; | ||
export type SelectorMatches = SelectorMatched | SelectorUnmatched; | ||
type SelectorMatched = { | ||
matched: true; | ||
selector: string; | ||
specificity: Specificity; | ||
data?: Record<string, string>; | ||
matched: true; | ||
selector: string; | ||
specificity: Specificity; | ||
data?: Record<string, string>; | ||
}; | ||
type SelectorUnmatched = { | ||
matched: false; | ||
matched: false; | ||
}; | ||
export declare function matchSelector(el: Node, selector: string | RegexSelector | undefined): SelectorMatches; | ||
export {}; |
@@ -1,7 +0,3 @@ | ||
export declare function regexSelectorMatches( | ||
reg: string, | ||
raw: string, | ||
ignoreCase: boolean, | ||
): { | ||
[x: string]: string; | ||
export declare function regexSelectorMatches(reg: string, raw: string, ignoreCase: boolean): { | ||
[x: string]: string; | ||
} | null; |
import type { SelectorResult, Specificity } from './types'; | ||
type ExtendedPseudoClass = Record<string, (content: string) => (el: Element) => SelectorResult>; | ||
export declare class Selector { | ||
#private; | ||
constructor(selector: string, extended?: ExtendedPseudoClass); | ||
match(el: Node, scope?: ParentNode | null): Specificity | false; | ||
search(el: Node, scope?: ParentNode | null): SelectorResult[]; | ||
#private; | ||
constructor(selector: string, extended?: ExtendedPseudoClass); | ||
match(el: Node, scope?: ParentNode | null): Specificity | false; | ||
search(el: Node, scope?: ParentNode | null): SelectorResult[]; | ||
} | ||
export {}; |
export type Specificity = [number, number, number]; | ||
export type SelectorResult = SelectorMatchedResult | SelectorUnmatchedResult; | ||
export type SelectorMatchedResult = { | ||
specificity: Specificity; | ||
matched: true; | ||
nodes: (Element | Text)[]; | ||
has: SelectorMatchedResult[]; | ||
specificity: Specificity; | ||
matched: true; | ||
nodes: (Element | Text)[]; | ||
has: SelectorMatchedResult[]; | ||
}; | ||
export type SelectorUnmatchedResult = { | ||
specificity: Specificity; | ||
matched: false; | ||
not?: SelectorMatchedResult[]; | ||
specificity: Specificity; | ||
matched: false; | ||
not?: SelectorMatchedResult[]; | ||
}; | ||
export type RegexSelector = RegexSelectorWithoutCombination & { | ||
combination?: { | ||
combinator: RegexSelectorCombinator; | ||
} & RegexSelector; | ||
combination?: { | ||
combinator: RegexSelectorCombinator; | ||
} & RegexSelector; | ||
}; | ||
export type RegexSelectorCombinator = ' ' | '>' | '+' | '~' | ':has(+)' | ':has(~)'; | ||
export type RegexSelectorWithoutCombination = { | ||
nodeName?: string; | ||
attrName?: string; | ||
attrValue?: string; | ||
nodeName?: string; | ||
attrName?: string; | ||
attrValue?: string; | ||
}; |
{ | ||
"name": "@markuplint/selector", | ||
"version": "3.0.0-alpha.6", | ||
"description": "W3C Selector and Regex selector", | ||
"version": "3.0.0-alpha.27+b5eef04a", | ||
"description": "Extended W3C Selectors matcher", | ||
"repository": "git@github.com:markuplint/markuplint.git", | ||
@@ -21,7 +21,7 @@ "author": "Yusuke Hirao <yusukehirao@me.com>", | ||
"debug": "^4.3.4", | ||
"postcss-selector-parser": "^6.0.10", | ||
"tslib": "^2.4.0" | ||
"postcss-selector-parser": "^6.0.11", | ||
"tslib": "^2.4.1" | ||
}, | ||
"devDependencies": { | ||
"@markuplint/ml-spec": "3.0.0-alpha.6", | ||
"@markuplint/ml-spec": "3.0.0-alpha.27+b5eef04a", | ||
"@types/debug": "^4.1.7", | ||
@@ -31,3 +31,3 @@ "@types/jsdom": "16", | ||
}, | ||
"gitHead": "b185a06d4ea09a1bf32458f7be4abe510eb57b89" | ||
"gitHead": "b5eef04a99177b25dccb164b486fba9fa01893ae" | ||
} |
# @markuplint/selector | ||
[![npm version](https://badge.fury.io/js/%40markuplint%2Fselector.svg)](https://www.npmjs.com/package/@markuplint/selector) | ||
[![Build Status](https://travis-ci.org/markuplint/markuplint.svg?branch=main)](https://travis-ci.org/markuplint/markuplint) | ||
[![Coverage Status](https://coveralls.io/repos/github/markuplint/markuplint/badge.svg?branch=main)](https://coveralls.io/github/markuplint/markuplint?branch=main) | ||
## Install | ||
**Extended [W3C Selectors](https://www.w3.org/TR/selectors-4/) matcher** | ||
```sh | ||
$ npm install @markuplint/selector | ||
$ yarn add @markuplint/selector | ||
``` | ||
## [W3C Selectors](https://www.w3.org/TR/selectors-4/) matcher | ||
Supported selectors and operators: | ||
@@ -123,1 +113,16 @@ | ||
``` | ||
## Install | ||
[`markuplint`](https://www.npmjs.com/package/markuplint) package includes this package. | ||
<details> | ||
<summary>If you are installing purposely, how below:</summary> | ||
```shell | ||
$ npm install @markuplint/selector | ||
$ yarn add @markuplint/selector | ||
``` | ||
</details> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
128
63029
29
1381
1
Updatedtslib@^2.4.1