UNPKG

accessibility-checker-engine

Version:

An automated accessibility checking engine for use by other tools

106 lines (102 loc) 4.65 kB
/****************************************************************************** Copyright:: 2020- IBM, Inc Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *****************************************************************************/ import { Context } from "./Context"; import { Issue, Rule, RuleContext, RuleContextHierarchy } from "../../v4/api/IRule"; import { HelpMap, IEngine, NlsMap } from "../../v4/api/IEngine"; import { IMapper } from "../../v4/api/IMapper"; import { Report } from "../../v4/api/IReport"; declare class WrappedRule { rule: Rule; parsedInfo: Context; ns: string; idx?: number; constructor(rule: Rule, parsedInfo: Context); /** * This function is responsible converting the node into a snippet which can be added to report. * * Note: This function will take the node and extract the node name and the attributes and build the snippet based on this. * * TODO: Future, maybe we can extract more then just single line, add more info or even add closing tags etc... * * @param {HTMLElement} node - The html element to convert into element snippet with node name and attributes only. * * @return {String} nodeSnippet - return the element snippet of the element that was provided which only contains, * nodename and attributes. i.e. <table id=\"layout_table1\" role=\"presentation\"> * * @memberOf this */ static convertNodeToSnippet(node: Element): string; /** * This function is responsible for finding the source location for a node, which can be added to a report. * Supports debug directives in the following forms: * 1. An attribute on the element itself: * ibm-a11y-debug="file.ts:10:5" * 2. A comment node preceding the element (as a sibling or ancestor sibling): * <!-- ibm-a11y-debug: file.ts:10:5 --> * 3. A wrapper element (e.g. div) whose first non-whitespace child is such a comment node. * 4. An ancestor element that carries the ibm-a11y-debug attribute. * * Traversal: checks the node itself for an inline attribute, then scans previous siblings at * each ancestor level upward (also checking each ancestor element's own inline attribute), * stopping if a blank or 'end' marker is found. * * @param {Node} node - The DOM node to find source info for * @return {string | null} - The source location string, or null if not found * * @memberOf this */ static convertNodeToSource(node: Node, enabled?: boolean): string; run(engine: Engine, context: RuleContext, options?: {}, contextHierarchies?: RuleContextHierarchy): Issue[]; } export declare class Engine implements IEngine { static getLanguages(): readonly string[]; mappers: { [namespace: string]: IMapper; }; ruleMap: { [id: string]: Rule; }; wrappedRuleMap: { [id: string]: WrappedRule; }; nlsMap: NlsMap; helpMap: HelpMap; sourceMapEnabled: boolean; private inclRules; private exclRules; constructor(); run(root: Document | Node, options?: {}): Promise<Report>; enableRules(ruleIds: string[]): void; getRule(ruleId: string): Rule; getRulesIds(): string[]; addRules(rules: Rule[]): void; addRule(rule: Rule, skipSort?: boolean): void; enableSourceMap(enable: boolean): void; isSourceMapEnabled(): boolean; _sortRules(): void; addNlsMap(map: NlsMap): void; addHelpMap(map: HelpMap): void; getMessage(ruleId: string, ruleIdx: number | string, msgArgs?: string[]): string; getHelp(ruleId: string, reasonId: number | string, archiveId?: string): string; getHelpRel(ruleId: string, ruleIdx: number | string): string; addMapper(mapper: IMapper): void; private static match; private getMatchingRules; /** * Sorts the rules in order to execute dependencies in the correct order * @param inRules List of wrapped rules to sort * @returns Sorted list of wrapped rules */ sortDeps(inRules: WrappedRule[]): WrappedRule[]; } export {};