Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typings: Fix ElementContext type #822

Merged
merged 2 commits into from
Apr 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions axe.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,14 @@ declare module axe {
type RunOnlyType = "rule" | "rules" | "tag" | "tags";

type RunOnlyObject = {
include?: string[],
exclude?: string[]
include?: string[] | string[][],
exclude?: string[] | string[][]
}

type RunCallback = (error: Error, results:AxeResults) => void;

interface ElementContext {
node?: Object,
selector?: string,
include?: any[],
exclude?: any[]
}
type ElementContext = Node | string | RunOnlyObject;

interface RunOnly {
type: RunOnlyType,
values?: TagValue[] | RunOnlyObject
Expand Down Expand Up @@ -132,7 +128,7 @@ declare module axe {
* @param {RunCallback} callback Optional The function to invoke when analysis is complete.
* @returns {Promise<AxeResults>|void} If the callback was not defined, aXe will return a Promise.
*/
function run(context: ElementContext): Promise<AxeResults>
function run(context?: ElementContext): Promise<AxeResults>
function run(options: RunOptions): Promise<AxeResults>
function run(callback: (error: Error, results:AxeResults) => void): void
function run(context: ElementContext, callback: RunCallback): void
Expand Down
4 changes: 2 additions & 2 deletions typings/axe-core/axe-core-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ axe.run({exclude: [$fixture[0]]}, {}, (error: Error, results: axe.AxeResults) =>
console.log(error || results)
})
// additional configuration options
axe.run(context, {iframes: false, selectors: false, elementRef: false},
axe.run(context, {iframes: false, selectors: false, elementRef: false},
(error: Error, results: axe.AxeResults) => {
console.log(error || results.passes.length);
});
Expand All @@ -45,7 +45,7 @@ axe.run(context, tagConfig, (error: Error, results: axe.AxeResults) => {
})
var includeExcludeTagsRunOnly: axe.RunOnly = {
type: 'tags',
value: {
values: {
include: ['wcag2a', 'wcag2aa'],
exclude: ['experimental']
}
Expand Down