Skip to content

Commit 5c96576

Browse files
committed
Export TS types.
1 parent baedf9e commit 5c96576

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "css-selector-parser",
3-
"version": "1.4.0",
3+
"version": "1.4.1",
44
"description": "Just a CSS selector parser.",
55
"keywords": [
66
"css",

src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import {PseudoSelectorType, parseCssSelector} from './parser-context';
2-
import {Selector} from './selector';
2+
import {
3+
Selector, RuleAttr, Rule, Selectors, SelectorEntity, RulePseudo, RuleSet, AttrValueType
4+
} from './selector';
35
import {renderEntity} from './render';
46

7+
export {Selector, RuleAttr, Rule, Selectors, SelectorEntity, RulePseudo, RuleSet, AttrValueType, PseudoSelectorType};
8+
59
export class CssSelectorParser {
610
protected pseudos: {[pseudo: string]: PseudoSelectorType} = {};
711
protected attrEqualityMods: {[mod: string]: true} = {};

src/parser-context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ export function parseCssSelector(
207207
} else if (chr === '[') {
208208
pos++;
209209
skipWhitespace();
210-
const attr: Partial<RuleAttr> = {
210+
let attr: any = {
211211
name: getIdent()
212212
};
213213
skipWhitespace();

src/render.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function renderEntity(entity: SelectorEntity) {
3737
}
3838
if (entity.attrs) {
3939
res += entity.attrs.map((attr) => {
40-
if (attr.operator) {
40+
if ('operator' in attr) {
4141
if (attr.valueType === 'substitute') {
4242
return "[" + escapeIdentifier(attr.name) + attr.operator + "$" + attr.value + "]";
4343
} else {

src/selector.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@ export interface Selectors {
1313

1414
export type AttrValueType = 'string' | 'substitute';
1515

16-
export interface RuleAttr {
17-
name: string;
16+
export type RuleAttr = {name: string} & ({} | {
1817
operator: string;
1918
valueType: AttrValueType;
2019
value: string;
21-
}
20+
});
2221

2322
export type RulePseudo = {
2423
name: string;

0 commit comments

Comments
 (0)