@tokey/css-selector-parser
Advanced tools
Comparing version 0.6.0 to 0.6.1
import type { ImmutableSelectorNode } from '../ast-types'; | ||
export declare type Specificity = [ | ||
export type Specificity = [ | ||
inlineLevel: number, | ||
@@ -4,0 +4,0 @@ idLevel: number, |
@@ -6,3 +6,3 @@ import type { SelectorNode, SelectorList, ImmutableSelectorNode, ImmutableSelectorList } from '../ast-types'; | ||
} | ||
export declare type WalkVisitor<AST extends SelectorNode | ImmutableSelectorNode> = (node: AST, index: number, nodes: AST[], parents: AST[]) => number | undefined | void; | ||
export type WalkVisitor<AST extends SelectorNode | ImmutableSelectorNode> = (node: AST, index: number, nodes: AST[], parents: AST[]) => number | undefined | void; | ||
/** | ||
@@ -9,0 +9,0 @@ * traverse each node of the selector AST from start to end. |
@@ -8,3 +8,3 @@ import type { Immutable } from './types'; | ||
} | ||
export declare type NthSelectorList = [Nth, ...SelectorList]; | ||
export type NthSelectorList = [Nth, ...SelectorList]; | ||
export interface PseudoClass extends Token<'pseudo_class'> { | ||
@@ -55,3 +55,3 @@ nodes?: SelectorList | NthSelectorList; | ||
} | ||
export declare type Invalid = Token<'invalid'>; | ||
export type Invalid = Token<'invalid'>; | ||
export interface Comment extends Token<'comment'> { | ||
@@ -61,3 +61,3 @@ before: string; | ||
} | ||
export declare type CommentWithNoSpacing = Comment & { | ||
export type CommentWithNoSpacing = Comment & { | ||
before: ''; | ||
@@ -71,7 +71,7 @@ after: ''; | ||
} | ||
export declare type NthStep = NthBase<'nth_step'>; | ||
export declare type NthOffset = NthBase<'nth_offset'>; | ||
export declare type NthDash = NthBase<'nth_dash'>; | ||
export declare type NthOf = NthBase<'nth_of'>; | ||
export declare type NthNode = NthStep | NthOffset | NthDash | NthOf | Comment; | ||
export type NthStep = NthBase<'nth_step'>; | ||
export type NthOffset = NthBase<'nth_offset'>; | ||
export type NthDash = NthBase<'nth_dash'>; | ||
export type NthOf = NthBase<'nth_of'>; | ||
export type NthNode = NthStep | NthOffset | NthDash | NthOf | Comment; | ||
export interface Nth extends Omit<Token<'nth'>, 'value'> { | ||
@@ -82,4 +82,4 @@ nodes: Array<NthNode>; | ||
} | ||
export declare type NamespacedNode = Type | Universal; | ||
export declare type SimpleSelector = Type | Universal | Attribute | Class | Id | PseudoClass; | ||
export type NamespacedNode = Type | Universal; | ||
export type SimpleSelector = Type | Universal | Attribute | Class | Id | PseudoClass; | ||
export interface CompoundSelector extends Omit<Token<'compound_selector'>, 'value'> { | ||
@@ -91,30 +91,30 @@ nodes: Array<SimpleSelector | Nesting | CommentWithNoSpacing | Invalid | PseudoElement | CompoundSelector | Selector>; | ||
} | ||
export declare type FunctionalSelector = NamespacedNode | Attribute | Id | Class | PseudoClass | PseudoElement | Nesting; | ||
export declare type SelectorNode = FunctionalSelector | Selector | CompoundSelector | Combinator | Comment | Invalid | Nth | NthStep | NthDash | NthOffset | NthOf; | ||
export declare type SelectorNodes = SelectorNode[]; | ||
export declare type SelectorList = Selector[]; | ||
export declare type ImmutableSelector = Immutable<Selector>; | ||
export declare type ImmutableCompoundSelector = Immutable<CompoundSelector>; | ||
export declare type ImmutableSelectorList = Immutable<SelectorList>; | ||
export declare type ImmutableNthSelectorList = Immutable<NthSelectorList>; | ||
export declare type ImmutableSelectorNode = Immutable<SelectorNode>; | ||
export declare type ImmutableFunctionalSelector = Immutable<FunctionalSelector>; | ||
export declare type ImmutableNamespacedNode = Immutable<NamespacedNode>; | ||
export declare type ImmutableUniversal = Immutable<Universal>; | ||
export declare type ImmutableClass = Immutable<Class>; | ||
export declare type ImmutableId = Immutable<Id>; | ||
export declare type ImmutableType = Immutable<Type>; | ||
export declare type ImmutableCombinator = Immutable<Combinator>; | ||
export declare type ImmutableAttribute = Immutable<Attribute>; | ||
export declare type ImmutablePseudoClass = Immutable<PseudoClass>; | ||
export declare type ImmutablePseudoElement = Immutable<PseudoElement>; | ||
export declare type ImmutableComment = Immutable<Comment>; | ||
export declare type ImmutableCommentWithNoSpacing = Immutable<CommentWithNoSpacing>; | ||
export declare type ImmutableNesting = Immutable<Nesting>; | ||
export declare type ImmutableInvalid = Immutable<Invalid>; | ||
export declare type ImmutableNth = Immutable<Nth>; | ||
export declare type ImmutableNthStep = Immutable<NthStep>; | ||
export declare type ImmutableNthDash = Immutable<NthDash>; | ||
export declare type ImmutableNthOffset = Immutable<NthOffset>; | ||
export declare type ImmutableNthOf = Immutable<NthOf>; | ||
export type FunctionalSelector = NamespacedNode | Attribute | Id | Class | PseudoClass | PseudoElement | Nesting; | ||
export type SelectorNode = FunctionalSelector | Selector | CompoundSelector | Combinator | Comment | Invalid | Nth | NthStep | NthDash | NthOffset | NthOf; | ||
export type SelectorNodes = SelectorNode[]; | ||
export type SelectorList = Selector[]; | ||
export type ImmutableSelector = Immutable<Selector>; | ||
export type ImmutableCompoundSelector = Immutable<CompoundSelector>; | ||
export type ImmutableSelectorList = Immutable<SelectorList>; | ||
export type ImmutableNthSelectorList = Immutable<NthSelectorList>; | ||
export type ImmutableSelectorNode = Immutable<SelectorNode>; | ||
export type ImmutableFunctionalSelector = Immutable<FunctionalSelector>; | ||
export type ImmutableNamespacedNode = Immutable<NamespacedNode>; | ||
export type ImmutableUniversal = Immutable<Universal>; | ||
export type ImmutableClass = Immutable<Class>; | ||
export type ImmutableId = Immutable<Id>; | ||
export type ImmutableType = Immutable<Type>; | ||
export type ImmutableCombinator = Immutable<Combinator>; | ||
export type ImmutableAttribute = Immutable<Attribute>; | ||
export type ImmutablePseudoClass = Immutable<PseudoClass>; | ||
export type ImmutablePseudoElement = Immutable<PseudoElement>; | ||
export type ImmutableComment = Immutable<Comment>; | ||
export type ImmutableCommentWithNoSpacing = Immutable<CommentWithNoSpacing>; | ||
export type ImmutableNesting = Immutable<Nesting>; | ||
export type ImmutableInvalid = Immutable<Invalid>; | ||
export type ImmutableNth = Immutable<Nth>; | ||
export type ImmutableNthStep = Immutable<NthStep>; | ||
export type ImmutableNthDash = Immutable<NthDash>; | ||
export type ImmutableNthOffset = Immutable<NthOffset>; | ||
export type ImmutableNthOf = Immutable<NthOf>; | ||
//# sourceMappingURL=ast-types.d.ts.map |
@@ -32,3 +32,3 @@ "use strict"; | ||
combinator: type, | ||
value: type === `space` ? ` ` : value, | ||
value: type === `space` ? value[0] : value, | ||
start, | ||
@@ -35,0 +35,0 @@ end, |
@@ -7,2 +7,8 @@ "use strict"; | ||
class NthParser { | ||
static isNthPseudoClass(name) { | ||
return (name === `nth-child` || | ||
name === `nth-last-child` || | ||
name === `nth-of-type` || | ||
name === `nth-last-of-type`); | ||
} | ||
constructor(selectorNode, s) { | ||
@@ -15,8 +21,2 @@ this.selectorNode = selectorNode; | ||
} | ||
static isNthPseudoClass(name) { | ||
return (name === `nth-child` || | ||
name === `nth-last-child` || | ||
name === `nth-of-type` || | ||
name === `nth-last-of-type`); | ||
} | ||
handleToken(token) { | ||
@@ -23,0 +23,0 @@ const type = token.type; |
import type { Token, Descriptors } from '@tokey/core'; | ||
declare type Delimiters = '[' | ']' | '(' | ')' | ',' | '*' | '|' | ':' | '.' | '#' | '>' | '~' | '+' | '{' | '}' | '&'; | ||
export declare type CSSSelectorToken = Token<Descriptors | Delimiters>; | ||
type Delimiters = '[' | ']' | '(' | ')' | ',' | '*' | '|' | ':' | '.' | '#' | '>' | '~' | '+' | '{' | '}' | '&'; | ||
export type CSSSelectorToken = Token<Descriptors | Delimiters>; | ||
export declare function tokenizeSelector(source: string, options?: { | ||
@@ -5,0 +5,0 @@ offset?: number; |
/** | ||
* convert object|array into a replica deep readonly type | ||
*/ | ||
export declare type Immutable<T> = T extends Function ? T : T extends object ? ImmutableMap<T> : T; | ||
export declare type ImmutableMap<T> = { | ||
export type Immutable<T> = T extends Function ? T : T extends object ? ImmutableMap<T> : T; | ||
export type ImmutableMap<T> = { | ||
readonly [P in keyof T]: Immutable<T[P]>; | ||
}; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@tokey/css-selector-parser", | ||
"description": "selector parser for css", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"main": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "types": "dist/index.d.ts", |
@@ -46,3 +46,3 @@ import type { CSSSelectorToken } from './tokenizer'; | ||
combinator: type, | ||
value: type === `space` ? ` ` : value, | ||
value: type === `space` ? value[0] : value, | ||
start, | ||
@@ -49,0 +49,0 @@ end, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
171404