Skip to content

Commit

Permalink
chore: Remove axe VirtualNode abstraction
Browse files Browse the repository at this point in the history
  • Loading branch information
WilcoFiers committed Nov 6, 2019
1 parent 9ac55c4 commit 3519c7b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 167 deletions.
112 changes: 0 additions & 112 deletions __tests__/src/util/JSXVirtualNode-test.js

This file was deleted.

24 changes: 14 additions & 10 deletions src/rules/autocomplete-valid.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
// ----------------------------------------------------------------------------
import { dom } from 'aria-query';
import { runVirtualRule } from 'axe-core';
import { elementType } from 'jsx-ast-utils';
import { elementType, getLiteralPropValue, getProp } from 'jsx-ast-utils';
import { generateObjSchema } from '../util/schemas';
import JSXVirtualNode from '../util/JSXVirtualNode';

const schema = generateObjSchema({
ignoreNonDOM: {
Expand All @@ -33,19 +32,24 @@ module.exports = {
// If true, then do not run rule.
const options = context.options[0] || {};
const ignoreNonDOM = !!options.ignoreNonDOM;
const nodeName = elementType(node);
const isDOMNode = dom.get(nodeName);
const elType = elementType(node);
const isDOMNode = dom.get(elType);
if (ignoreNonDOM && !isDOMNode) {
return;
}

// If not a DOM node, assume an input element
const vNode = new JSXVirtualNode({
props: { nodeName: isDOMNode ? nodeName : 'input' },
attrs: node.attributes,
});
const attr = (attrName) => {
const value = getLiteralPropValue(getProp(node.attributes, attrName));
return (typeof value === 'string' ? value : null);
};
const props = {
nodeName: isDOMNode ? elType : 'input',
nodeType: 1,
};
const hasAttr = attrName => attr(attrName) !== null;

const { violations } = runVirtualRule('autocomplete-valid', { attr, props, hasAttr });

const { violations } = runVirtualRule('autocomplete-valid', vNode);
if (violations.length === 0) {
return;
}
Expand Down
45 changes: 0 additions & 45 deletions src/util/JSXVirtualNode.js

This file was deleted.

0 comments on commit 3519c7b

Please sign in to comment.