Skip to content

Commit

Permalink
fix(types): Fixed last context types
Browse files Browse the repository at this point in the history
  • Loading branch information
fb55 committed Apr 16, 2021
1 parent 600a774 commit e15cc53
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function wrapCompile<Selector, Node, ElementNode extends Node>(
return function addAdapter(
selector: Selector,
options?: Options<Node, ElementNode>,
context?: Node[]
context?: Node[] | Node
) {
const opts = convertOptionFormats(options);

Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export interface Options<Node, ElementNode extends Node> {
* The context of the current query. Used to limit the scope of searches.
* Can be matched directly using the `:scope` pseudo-selector.
*/
context?: ElementNode | ElementNode[];
context?: Node | Node[];
/**
* Allow css-select to cache results for some selectors, sometimes greatly
* improving querying performance. Disable this if your document can
Expand Down Expand Up @@ -145,5 +145,5 @@ export type Query<ElementNode> =
export type CompileToken<Node, ElementNode extends Node> = (
token: InternalSelector[][],
options: InternalOptions<Node, ElementNode>,
context?: Node[]
context?: Node[] | Node
) => CompiledQuery<ElementNode>;
2 changes: 2 additions & 0 deletions test/qwery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ const doc = parseDOM(

const el = DomUtils.getElementById("attr-child-boosh", document);

if (!el) throw new Error("Couldn't find element");

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const pseudos = DomUtils.getElementById("pseudos", document)!.children.filter(
DomUtils.isTag
Expand Down

0 comments on commit e15cc53

Please sign in to comment.