@uuv/a11y
Version:
A javascript lib for running a11y validation based on multiple reference(RGAA, etc)
74 lines (73 loc) • 3.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AttributeChecker = exports.CompliantSpecification = void 0;
const attribut_specification_1 = require("./attribut-specification");
class CompliantSpecification {
attribute;
specification;
constructor(attribute, specification) {
this.attribute = attribute;
this.specification = specification;
}
}
exports.CompliantSpecification = CompliantSpecification;
class AttributeChecker {
/**
* Check if the value of the attributeName is empty
* @param attributeName : HTMLElement attributeName
*/
static emptyAttribute(attributeName) {
return new CompliantSpecification(attributeName, new attribut_specification_1.EmptyAttributeSpecification());
}
/**
* Check if the value of the attributeName is not empty
* @param attributeName : HTMLElement attributeName
*/
static notEmptyAttribute(attributeName) {
return new CompliantSpecification(attributeName, new attribut_specification_1.NotEmptyAttributeSpecification());
}
/**
* Check that the text of the HTMLElement whose id matches the value of the attribute named attributeName another HTMLElement is empty
* @param attributeName : HTMLElement attribute name
*/
static emptyHtmlNodeTargetedByTheAttribute(attributeName) {
return new CompliantSpecification(attributeName, new attribut_specification_1.EmptyElementWithIdSpecification());
}
/**
* Check that id attribute is not unique in current page
*/
static notUniqueId() {
return new CompliantSpecification("id", new attribut_specification_1.NotUniqueIdAttributeSpecification());
}
/**
* Check that html element does not have the expected value
*/
static notEquals(attributeName, expectedValueList) {
return new CompliantSpecification(attributeName, new attribut_specification_1.NotEqualsAttributeSpecification(expectedValueList));
}
/**
* Check that html element have the expected value
*/
static equals(attributeName, expectedValueList) {
return new CompliantSpecification(attributeName, new attribut_specification_1.EqualsAttributeSpecification(expectedValueList));
}
/**
* Check that html element accessible name contains visible text ignoring case
*/
static accessibleNameNotContainsVisibleText() {
return new CompliantSpecification("accessibleName", new attribut_specification_1.AccessibleNameNotContainsVisibleTextSpecification());
}
/**
* Check that html element have empty text
*/
static emptyText() {
return new CompliantSpecification("text", new attribut_specification_1.EmptyInnerTextSpecification());
}
/**
* Check that html element have not empty text
*/
static notEmptyText() {
return new CompliantSpecification("text", new attribut_specification_1.NotEmptyInnerTextSpecification());
}
}
exports.AttributeChecker = AttributeChecker;