index.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*exported axe, commons */
  2. /*global axeFunction, module, define */
  3. // exported namespace for axe
  4. /*eslint no-use-before-define: 0, no-unused-vars: 0*/
  5. var axe = axe || {};
  6. axe.version = '<%= pkg.version %>';
  7. if (typeof define === 'function' && define.amd) {
  8. // Explicitly naming the module to avoid mismatched anonymous define() modules when injected in a page
  9. define('axe-core', [], () => axe);
  10. }
  11. if (
  12. typeof module === 'object' &&
  13. module.exports &&
  14. typeof axeFunction.toString === 'function'
  15. ) {
  16. axe.source =
  17. '(' +
  18. axeFunction.toString() +
  19. ')(typeof window === "object" ? window : this);';
  20. module.exports = axe;
  21. }
  22. if (typeof window.getComputedStyle === 'function') {
  23. window.axe = axe;
  24. }
  25. // local namespace for common functions
  26. var commons;
  27. function SupportError(error) {
  28. this.name = 'SupportError';
  29. this.cause = error.cause;
  30. this.message = `\`${error.cause}\` - feature unsupported in your environment.`;
  31. if (error.ruleId) {
  32. this.ruleId = error.ruleId;
  33. this.message += ` Skipping ${this.ruleId} rule.`;
  34. }
  35. this.stack = new Error().stack;
  36. }
  37. SupportError.prototype = Object.create(Error.prototype);
  38. SupportError.prototype.constructor = SupportError;