Skip to content

Commit

Permalink
chore: WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
WilcoFiers committed Oct 28, 2018
1 parent abb0673 commit ae48c16
Show file tree
Hide file tree
Showing 14 changed files with 346 additions and 16 deletions.
Empty file added .scannerwork/.sonar_lock
Empty file.
14 changes: 14 additions & 0 deletions .scannerwork/css-bundle/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "css-bundle",
"version": "1.0.0",
"description": "Simple node project to run stylelint from SonarCSS",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "LGPL-3.0",
"dependencies": {
"stylelint": "9.2.1"
}
}
1 change: 1 addition & 0 deletions .scannerwork/css-bundle/stylelintconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"rules":{"block-no-empty":true,"string-no-newline":true,"comment-no-empty":true,"function-linear-gradient-no-nonstandard-direction":true,"media-feature-name-no-unknown":true,"color-no-invalid-hex":true,"no-descending-specificity":true,"font-family-no-duplicate-names":true,"no-duplicate-at-import-rules":true,"declaration-block-no-duplicate-properties":[true,{"ignore":["consecutive-duplicates-with-different-values"]}],"no-empty-source":true,"selector-type-no-unknown":true,"at-rule-no-unknown":[true,{"ignoreAtRules":["at-root","content","debug","each","else","error","for","function","if","include","mixin","return","warn","while"]}],"no-duplicate-selectors":true,"font-family-no-missing-generic-family-keyword":true,"no-extra-semicolons":true,"no-invalid-double-slash-comments":true,"selector-pseudo-element-no-unknown":true,"selector-pseudo-class-no-unknown":true,"keyframe-declaration-no-important":true,"function-calc-no-unspaced-operator":true,"property-no-unknown":true,"declaration-block-no-shorthand-property-overrides":true,"unit-no-unknown":true}}
7 changes: 7 additions & 0 deletions .scannerwork/report-task.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
organization=wilcofiers-github
projectKey=WilcoFiers_axe-core
serverUrl=https://sonarcloud.io
serverVersion=7.4.0.18669
dashboardUrl=https://sonarcloud.io/dashboard?id=WilcoFiers_axe-core
ceTaskId=AWa39rVxpAwoMVoOEi-z
ceTaskUrl=https://sonarcloud.io/api/ce/task?id=AWa39rVxpAwoMVoOEi-z
10 changes: 10 additions & 0 deletions .scannerwork/sonarts-bundle/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "sonarts-bundle",
"version": "1.0.0",
"description": "bundle for the SonarTS-Plugin",
"license": "LGPL-3.0",
"devDependencies": {
"tslint": "5.11.0",
"tslint-sonarts": "file:../../../sonarts-core/tslint-sonarts-1.8.0.tgz"
}
}
8 changes: 4 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,14 +386,14 @@ module.exports = function(grunt) {
grunt.registerTask('build', [
'clean',
'generate-imports',
'eslint',
// 'eslint',
'validate',
'concat:commons',
'configure',
'babel',
'concat:engine',
'uglify',
'aria-supported'
'concat:engine'
// 'uglify',
// 'aria-supported'
]);

grunt.registerTask('test', [
Expand Down
1 change: 1 addition & 0 deletions axe.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ declare namespace axe {
elementRef?: boolean;
selectors?: boolean;
resultTypes?: resultGroups[];
reporter?: string;
}
interface AxeResults {
url: string;
Expand Down
1 change: 0 additions & 1 deletion lib/checks/label/implicit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const { dom, text } = axe.commons;

var label = dom.findUpVirtual(virtualNode, 'label');
if (label) {
console.log(label);
return !!text.accessibleText(label, { inControlContext: true });
}
return false;
7 changes: 6 additions & 1 deletion lib/commons/aria/get-aria-labelledby-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,14 @@ aria.getAriaLabelledbyText = function getAriaLabelledbyText(
inLabelledByContext: true,
// Allow hidden content if the elm is hidden
includeHidden: !dom.isVisible(elm, true),
startNode: context.startNode || node,
...context
});

return accessibleName + ' ' + accessibleNameAdd;
if (!accessibleName) {
return accessibleNameAdd;
} else {
return accessibleName + ' ' + accessibleNameAdd;
}
}, '');
};
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
/* global aria, dom */
aria.getOwnedVirtual = function getOwned({ actualNode, children }) {
if (!actualNode || !children) {
throw new Error('getOwnedVirtual requires a virtual node');
}
return dom.idrefs(actualNode, 'aria-owns').reduce((ownedElm, element) => {
if (element) {
let virtualNode = axe.utils.getNodeFromTree(axe._tree[0], element);
const virtualNode = axe.utils.getNodeFromTree(axe._tree[0], element);
ownedElm.push(virtualNode);
}
return ownedElm;
Expand Down
34 changes: 34 additions & 0 deletions test/commons/aria/get-aria-label-text.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
describe('aria.getAriaLabelText', function() {
'use strict';
var aria = axe.commons.aria;

it('returns "" if there is no aria-label', function() {
var node = document.createElement('div');
assert.equal(aria.getAriaLabelText(node), '');
});

it('returns the aria-label attribute of nodes', function() {
var node = document.createElement('div');
var label = ' my label ';
node.setAttribute('aria-label', label);
assert.equal(aria.getAriaLabelText(node), label);
});

it('returns the aria-label attribute of virtual nodes', function() {
var node = document.createElement('div');
var label = ' my label ';
node.setAttribute('aria-label', label);
const vNode = { actualNode: node };
assert.equal(aria.getAriaLabelText(vNode), label);
});

it('returns "" if there is no aria-label', function() {
var node = document.createElement('div');
assert.equal(aria.getAriaLabelText(node), '');
});

it('returns "" if the node is not an element', function() {
var node = document.createTextNode('my text node');
assert.equal(aria.getAriaLabelText(node), '');
});
});
117 changes: 117 additions & 0 deletions test/commons/aria/get-aria-labelledby-text.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
describe('aria.getAriaLabelledbyText', function() {
'use strict';
var aria = axe.commons.aria;
var fixtureSetup = axe.testUtils.fixtureSetup;

it('returns the accessible name of the aria-labelledby references', function() {
var fixture = fixtureSetup(
'<div role="heading" aria-labelledby="foo"></div>' +
'<div id="foo">Foo text</div>'
);
var accName = aria.getAriaLabelledbyText(fixture.firstChild);
assert.equal(accName, 'Foo text');
});

it('works with virtual nodes', function() {
fixtureSetup(
'<div role="heading" id="hdr" aria-labelledby="foo"></div>' +
'<div id="foo">Foo text</div>'
);
var target = axe.utils.querySelectorAll(axe._tree[0], '#hdr')[0];
var accName = aria.getAriaLabelledbyText(target);
assert.equal(accName, 'Foo text');
});

it('returns references in order', function() {
var fixture = fixtureSetup(
'<div role="heading" aria-labelledby="bar baz foo"></div>' +
'<div id="foo">Foo</div>' +
'<div id="bar">Bar</div>' +
'<div id="baz">Baz</div>'
);
var accName = aria.getAriaLabelledbyText(fixture.firstChild);
assert.equal(accName, 'Bar Baz Foo');
});

it('returns "" if the node is not an element', function() {
var fixture = fixtureSetup('foo');
var accName = aria.getAriaLabelledbyText(fixture.firstChild);
assert.equal(accName, '');
});

it('returns "" with context.inLabelledByContext: true', function() {
fixtureSetup(
'<div role="heading" id="hdr" aria-labelledby="foo"></div>' +
'<div id="foo">Foo text</div>'
);
var target = axe.utils.querySelectorAll(axe._tree[0], '#hdr')[0];
var accName = aria.getAriaLabelledbyText(target, {
inLabelledByContext: true
});
assert.equal(accName, '');
});

it('returns "" with context.inControlContext: true', function() {
fixtureSetup(
'<div role="heading" id="hdr" aria-labelledby="foo"></div>' +
'<div id="foo">Foo text</div>'
);
var target = axe.utils.querySelectorAll(axe._tree[0], '#hdr')[0];
var accName = aria.getAriaLabelledbyText(target, {
inControlContext: true
});
assert.equal(accName, '');
});

it('returns content of a aria-hidden reference', function() {
fixtureSetup(
'<div role="heading" id="hdr" aria-labelledby="foo"></div>' +
'<div id="foo" aria-hidden="true">Foo text</div>'
);
var target = axe.utils.querySelectorAll(axe._tree[0], '#hdr')[0];
var accName = aria.getAriaLabelledbyText(target);
assert.equal(accName, 'Foo text');
});

it('returns content of a `display:none` reference', function() {
fixtureSetup(
'<div role="heading" id="hdr" aria-labelledby="foo"></div>' +
'<div id="foo" style="display:none">Foo text</div>'
);
var target = axe.utils.querySelectorAll(axe._tree[0], '#hdr')[0];
var accName = aria.getAriaLabelledbyText(target);
assert.equal(accName, 'Foo text');
});

it('returns does not return hidden content of a visible reference', function() {
fixtureSetup(
'<div role="heading" id="hdr" aria-labelledby="foo"></div>' +
'<div id="foo"><div style="display:none">Foo text</div></div>'
);
var target = axe.utils.querySelectorAll(axe._tree[0], '#hdr')[0];
var accName = aria.getAriaLabelledbyText(target);
assert.equal(accName, '');
});

it('does not follow more than one aria-labelledy reference', function() {
fixtureSetup(
'<div role="heading" id="hdr" aria-labelledby="foo"></div>' +
'<div id="foo"><div aria-labelledby="bar" role="heading"></div></div>' +
'<div id="bar">Foo text</div>'
);
var target = axe.utils.querySelectorAll(axe._tree[0], '#hdr')[0];
var accName = aria.getAriaLabelledbyText(target, {
inControlContext: true
});
assert.equal(accName, '');
});

it('preserves spacing', function() {
var fixture = fixtureSetup(
'<div role="heading" aria-labelledby="foo"></div>' +
'<div id="foo"> \t Foo \n text \t </div>'
);
var accName = aria.getAriaLabelledbyText(fixture.firstChild);
assert.equal(accName, ' \t Foo \n text \t ');
});
});
47 changes: 47 additions & 0 deletions test/commons/aria/get-owned-virtual.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
describe('aria.getOwnedVirtual', function() {
'use strict';
var aria = axe.commons.aria;
var fixtureSetup = axe.testUtils.fixtureSetup;

it('returns a list of children in order', function() {
fixtureSetup(
'<div id="target">' +
'<h1>heading 1</h1>' +
'<h2>heading 2</h2>' +
'<h3>heading 3</h3>' +
'</div>'
);
var target = axe.utils.querySelectorAll(axe._tree[0], '#target')[0];
var owned = aria.getOwnedVirtual(target);
assert.lengthOf(owned, 3);
assert.equal(owned[0].actualNode.nodeName.toUpperCase(), 'H1');
assert.equal(owned[1].actualNode.nodeName.toUpperCase(), 'H2');
assert.equal(owned[2].actualNode.nodeName.toUpperCase(), 'H3');
});

it('adds aria-owned reffed elements to the children', function() {
fixtureSetup(
'<div id="target" aria-owns="hdr3 hdr4">' +
'<h1>heading 1</h1>' +
'<h2>heading 2</h2>' +
'</div>' +
'<h4 id="hdr4">heading 4</h4>' +
'<h3 id="hdr3">heading 3</h3>'
);
var target = axe.utils.querySelectorAll(axe._tree[0], '#target')[0];
var owned = aria.getOwnedVirtual(target);
assert.lengthOf(owned, 4);
assert.equal(owned[0].actualNode.nodeName.toUpperCase(), 'H1');
assert.equal(owned[1].actualNode.nodeName.toUpperCase(), 'H2');
assert.equal(owned[2].actualNode.nodeName.toUpperCase(), 'H3');
assert.equal(owned[2].actualNode.nodeName.toUpperCase(), 'H4');
});

it('ignores whitespace-only aria-owned');

it('ignores broken aria-owned refs');

it('includes text nodes');

it('returns an empty array if there are no owned elements');
});

0 comments on commit ae48c16

Please sign in to comment.