Skip to content
This repository has been archived by the owner on Sep 24, 2019. It is now read-only.

Commit

Permalink
Hacking at the jQuery weeds
Browse files Browse the repository at this point in the history
  • Loading branch information
jessebeach committed Dec 17, 2015
1 parent 96490cd commit 1787f1d
Show file tree
Hide file tree
Showing 36 changed files with 10,166 additions and 5,209 deletions.
4 changes: 1 addition & 3 deletions .quailrc
@@ -1,13 +1,11 @@
{
"assessmentSpecsPath": "test/assessmentSpecs/specs",
"jquery": "node_modules/jquery/dist/jquery.min.js",
"quail": "dist/runInBrowser.js",
"requireModules": [],
"requireAssessmentModules": [
"config/all_assessments.json"
],
"requirePaths": [
"./src/assessments",
"./vendor"
"./src/assessments"
]
}
7,613 changes: 5,049 additions & 2,564 deletions dist/bundle.js

Large diffs are not rendered by default.

7,619 changes: 5,052 additions & 2,567 deletions dist/runInBrowser.js

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions package.json
Expand Up @@ -27,7 +27,6 @@
"glob": "^6.0.1",
"guesslanguage": "^0.2.0",
"http-server": "0.7.3",
"jquery": "^2.1.4",
"phantomjs": "^1.9.18",
"progress": "^1.1.8",
"q": "^1.1.2",
Expand All @@ -43,7 +42,6 @@
"chai-as-promised": "^4.1.1",
"chai-spies": "^0.5.1",
"deepmerge": "^0.2.7",
"dom-select": "^1.1.0",
"eslint": "^1.3.1",
"jscs": "jscs-dev/node-jscs#c5adeba",
"mocha": "^2.0.1",
Expand Down
8 changes: 4 additions & 4 deletions src/assessments/AAdjacentWithSameResourceShouldBeCombined.js
Expand Up @@ -7,16 +7,16 @@ var AAdjacentWithSameResourceShouldBeCombined = {
// Find all the links
var $links = $element.find('a');
// Sort them into singletons and coupletons.
var $singletons = $();
var $coupletons = $();
var $singletons = [];
var $coupletons = [];

$links.each(function (index, link) {
var $link = $(link);
if ($link.next().is('a')) {
$coupletons = $coupletons.add($link);
$coupletons.push($link);
}
else {
$singletons = $singletons.add($link);
$singletons.push($link);
}
});

Expand Down
6 changes: 3 additions & 3 deletions src/assessments/ALinkWithNonText.js
@@ -1,6 +1,6 @@
var Case = require('Case');
var IsUnreadable = require('IsUnreadable');
var select = require('dom-select');
var DOM = require('DOM');
var ALinkWithNonText = {
run: function (test) {
test.get('$scope').find('a').each(function () {
Expand All @@ -21,13 +21,13 @@ var ALinkWithNonText = {
return;
}
var unreadable = 0;
select.all('img, object, embed', this).each(function () {
DOM.scry('img, object, embed', this).each(function () {
if (($(this).is('img') && IsUnreadable($(this).attr('alt'))) ||
(!$(this).is('img') && IsUnreadable($(this).attr('title')))) {
unreadable++;
}
});
if (select.all('img, object, embed', this).length === unreadable) {
if (DOM.scry('img, object, embed', this).length === unreadable) {
_case.set({
status: 'failed'
});
Expand Down
4 changes: 2 additions & 2 deletions src/assessments/AMustHaveTitle.js
@@ -1,9 +1,9 @@
var Case = require('Case');
var select = require('dom-select');
var DOM = require('DOM');
var AMustHaveTitle = {
run: function (test) {
this.get('$scope').each(function () {
var links = select.all('a', this);
var links = DOM.scry('a', this);

links.each(function (i, link) {
// Has a title attribute and that attribute has a value, then pass.
Expand Down
4 changes: 2 additions & 2 deletions src/assessments/ASuspiciousLinkText.js
@@ -1,7 +1,7 @@
var CleanStringComponent = require('CleanStringComponent');
var Case = require('Case');
var SuspiciousLinksStringsComponent = require('SuspiciousLinksStringsComponent');
var select = require('dom-select');
var DOM = require('DOM');
var ASuspiciousLinkText = {
run: function (test) {
test.get('$scope').find('a').each(function () {
Expand All @@ -16,7 +16,7 @@ var ASuspiciousLinkText = {
return;
}
var text = $(this).text();
select.all('img[alt]', this).each(function () {
DOM.scry('img[alt]', this).each(function () {
text = text + $(this).attr('alt');
});
if (SuspiciousLinksStringsComponent.indexOf(CleanStringComponent(text)) > -1) {
Expand Down
2 changes: 1 addition & 1 deletion src/assessments/AreaAltIdentifiesDestination.js
Expand Up @@ -6,7 +6,7 @@
* one. The test passes is the selector finds no matching elements.
*/
var Case = require('Case');
var $ = require('jquery/dist/jquery');
var DOM = require('DOM');

var AreaAltIdentifiesDestination = {
run: function (test, options) {
Expand Down
4 changes: 2 additions & 2 deletions src/assessments/DefinitionListsAreUsed.js
@@ -1,5 +1,5 @@
var Case = require('Case');
var select = require('dom-select');
var DOM = require('DOM');
var DefinitionListsAreUsed = {
run: function (test) {
test.get('$scope').find('dl').each(function () {
Expand All @@ -17,7 +17,7 @@ var DefinitionListsAreUsed = {
});
test.add(_case);
var $item = $(this);
select.all('span, strong, em, b, i', this).each(function () {
DOM.scry('span, strong, em, b, i', this).each(function () {
if ($(this).text().length < 50 && $item.text().search($(this).text()) === 0) {
if ($(this).is('span')) {
if ($(this).css('font-weight') === $item.css('font-weight') &&
Expand Down
4 changes: 2 additions & 2 deletions src/assessments/DocumentIDsMustBeUnique.js
@@ -1,5 +1,5 @@
var Case = require('Case');
var select = require('dom-select');
var DOM = require('DOM');
var DocumentIDsMustBeUnique = {
run: function (test) {
test.get('$scope').each(function () {
Expand All @@ -18,7 +18,7 @@ var DocumentIDsMustBeUnique = {
});
test.get('$scope').each(function () {
var ids = {};
select.all('[id]', this).each(function () {
DOM.scry('[id]', this).each(function () {
var _case = Case({
element: this
});
Expand Down
2 changes: 1 addition & 1 deletion src/assessments/DomOrderMatchesVisualOrder.js
Expand Up @@ -6,7 +6,7 @@
* one. The test passes is the selector finds no matching elements.
*/
var Case = require('Case');
var $ = require('jquery/dist/jquery');
var DOM = require('DOM');

var DomOrderMatchesVisualOrder = {
run: function (test, options) {
Expand Down
4 changes: 2 additions & 2 deletions src/assessments/EmbedHasAssociatedNoEmbed.js
@@ -1,5 +1,5 @@
var Case = require('Case');
var select = require('dom-select');
var DOM = require('DOM');
var EmbedHasAssociatedNoEmbed = {
run: function (test) {
test.get('$scope').find('embed').each(function () {
Expand All @@ -8,7 +8,7 @@ var EmbedHasAssociatedNoEmbed = {
});
test.add(_case);
_case.set({
status: (select.all('noembed').length || $(this).next().is('noembed', this)) ? 'passed' : 'failed'
status: (DOM.scry('noembed').length || $(this).next().is('noembed', this)) ? 'passed' : 'failed'
});
});
},
Expand Down
4 changes: 2 additions & 2 deletions src/assessments/FormHasSubmitButton.js
Expand Up @@ -6,14 +6,14 @@
* one. The test passes is the selector finds no matching elements.
*/
var Case = require('Case');
var select = require('dom-select');
var DOM = require('DOM');
var FormHasSubmitButton = {
run: function (test) {

var selector = 'input[type=submit], button[type=submit]';

this.get('$scope').each(function () {
var candidates = select.all('form', this);
var candidates = DOM.scry('form', this);

if (candidates.length === 0) {
test.add(Case({
Expand Down
4 changes: 2 additions & 2 deletions src/assessments/HeadersAttrRefersToATableCell.js
@@ -1,13 +1,13 @@
var Case = require('Case');
var select = require('dom-select');
var DOM = require('DOM');
var HeadersAttrRefersToATableCell = {
run: function (test) {
// Table cell headers without referred ids
test.get('$scope').find('table').each(function () {
var self = this;
var _case = Case();
test.add(_case);
var elmHeaders = select.all('th[headers], td[headers]', self);
var elmHeaders = DOM.scry('th[headers], td[headers]', self);

if (elmHeaders.length === 0) {
_case.set({
Expand Down
4 changes: 2 additions & 2 deletions src/assessments/HeadersUseToMarkSections.js
@@ -1,5 +1,5 @@
var Case = require('Case');
var select = require('dom-select');
var DOM = require('DOM');
var HeadersUseToMarkSections = {
run: function (test) {
test.get('$scope').find('p').each(function () {
Expand Down Expand Up @@ -30,7 +30,7 @@ var HeadersUseToMarkSections = {
}
var isNavigation = true;
$list.find('li:has(a)').each(function () {
if (select.all('a:first', this).text().trim() !== $(this).text().trim()) {
if (DOM.scry('a:first', this).text().trim() !== $(this).text().trim()) {
isNavigation = false;
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/assessments/ImgWithMathShouldHaveMathEquivalent.js
@@ -1,13 +1,13 @@
var Case = require('Case');
var select = require('dom-select');
var DOM = require('DOM');
var ImgWithMathShouldHaveMathEquivalent = {
run: function (test) {
test.get('$scope').find('img:not(img:has(math), img:has(tagName))').each(function () {
var _case = Case({
element: this
});
test.add(_case);
if (!select.all('math', this).parent().length) {
if (!DOM.scry('math', this).parent().length) {
_case.set({
status: 'failed'
});
Expand Down
4 changes: 2 additions & 2 deletions src/assessments/InputWithoutLabelHasTitle.js
@@ -1,12 +1,12 @@
var Case = require('Case');
var IsUnreadable = require('IsUnreadable');
var select = require('dom-select');
var DOM = require('DOM');
var InputWithoutLabelHasTitle = {
run: function (test) {

test.get('$scope').each(function () {

var testableElements = select.all('input, select, textarea', this);
var testableElements = DOM.scry('input, select, textarea', this);

if (testableElements.length === 0) {
var _case = Case({
Expand Down
4 changes: 2 additions & 2 deletions src/assessments/LabelDoesNotContainInput.js
Expand Up @@ -6,7 +6,7 @@
* one. The test passes is the selector finds no matching elements.
*/
var Case = require('Case');
var select = require('dom-select');
var DOM = require('DOM');
var LabelDoesNotContainInput = {
run: function (test) {

Expand All @@ -24,7 +24,7 @@ var LabelDoesNotContainInput = {
candidates.each(function () {
var status = 'passed';

if (select.all('input', this).length > 0) {
if (DOM.scry('input', this).length > 0) {
status = 'failed';
}

Expand Down
2 changes: 1 addition & 1 deletion src/assessments/ListNotUsedForFormatting.js
Expand Up @@ -6,7 +6,7 @@ var ListNotUsedForFormatting = {
element: this
});
test.add(_case);
if (select.all('li', this).length < 2) {
if (DOM.scry('li', this).length < 2) {
_case.set({
status: 'failed'
});
Expand Down
4 changes: 2 additions & 2 deletions src/assessments/ObjectMustHaveEmbed.js
Expand Up @@ -6,7 +6,7 @@
* one. The test passes is the selector finds no matching elements.
*/
var Case = require('Case');
var select = require('dom-select');
var DOM = require('DOM');
var ObjectMustHaveEmbed = {
run: function (test) {

Expand All @@ -23,7 +23,7 @@ var ObjectMustHaveEmbed = {
else {
candidates.each(function () {
var status = 'failed';
var hasEmbed = select.all('embed', this).length > 0;
var hasEmbed = DOM.scry('embed', this).length > 0;

// If a test is defined, then use it
if (hasEmbed) {
Expand Down
2 changes: 1 addition & 1 deletion src/assessments/ScriptFocusIndicatorVisible.js
@@ -1,6 +1,6 @@
var ConvertToPxComponent = require('ConvertToPxComponent');
var FocusElements = require('FocusElements');
var $ = require('jquery/dist/jquery');
var DOM = require('DOM');

var ScriptFocusIndicatorVisible = {
run: function () {
Expand Down
4 changes: 2 additions & 2 deletions src/assessments/SelectJumpMenu.js
@@ -1,6 +1,6 @@
var Case = require('Case');
var HasEventListenerComponent = require('HasEventListenerComponent');
var select = require('dom-select');
var DOM = require('DOM');
var SelectJumpMenu = {
run: function (test) {
var $scope = test.get('$scope');
Expand All @@ -9,7 +9,7 @@ var SelectJumpMenu = {
}

$scope.find('select').each(function () {
if (select.all(':submit', this).parent('form').length === 0 &&
if (DOM.scry(':submit', this).parent('form').length === 0 &&
HasEventListenerComponent($(this), 'change')) {
test.add(Case({
element: this,
Expand Down
2 changes: 1 addition & 1 deletion src/assessments/SiteMap.js
@@ -1,6 +1,6 @@
var Case = require('Case');
var SiteMapStringsComponent = require('SiteMapStringsComponent');
var $ = require('jquery/dist/jquery');
var DOM = require('DOM');

var SiteMap = {
run: function (test) {
Expand Down
4 changes: 2 additions & 2 deletions src/assessments/SvgContainsTitle.js
Expand Up @@ -6,7 +6,7 @@
* one. The test passes is the selector finds no matching elements.
*/
var Case = require('Case');
var select = require('dom-select');
var DOM = require('DOM');
var SvgContainsTitle = {
run: function (test) {

Expand All @@ -23,7 +23,7 @@ var SvgContainsTitle = {
else {
candidates.each(function () {
var status = 'failed';
var hasTitle = select.all('title', this).length === 1;
var hasTitle = DOM.scry('title', this).length === 1;

// If a test is defined, then use it
if (hasTitle) {
Expand Down
4 changes: 2 additions & 2 deletions src/assessments/TableAxisHasCorrespondingId.js
@@ -1,13 +1,13 @@
var Case = require('Case');
var select = require('dom-select');
var DOM = require('DOM');
var TableAxisHasCorrespondingId = {
run: function (test) {
test.get('$scope').find('[axis]').each(function () {
var _case = Case({
element: this
});
test.add(_case);
if (select.all('th#' + $(this).attr('axis', this).parents('table').first()).length === 0) {
if (DOM.scry('th#' + $(this).attr('axis', this).parents('table').first()).length === 0) {
_case.set({
status: 'failed'
});
Expand Down
4 changes: 2 additions & 2 deletions src/assessments/TableDataShouldHaveTh.js
Expand Up @@ -6,7 +6,7 @@
* one. The test passes is the selector finds no matching elements.
*/
var Case = require('Case');
var select = require('dom-select');
var DOM = require('DOM');
var TableDataShouldHaveTh = {
run: function (test) {

Expand All @@ -23,7 +23,7 @@ var TableDataShouldHaveTh = {
else {
candidates.each(function () {
var status = 'failed';
var hasHeading = select.all('th', this).length > 0;
var hasHeading = DOM.scry('th', this).length > 0;
// If a test is defined, then use it
if (hasHeading) {
status = 'passed';
Expand Down
4 changes: 2 additions & 2 deletions src/assessments/TableLayoutDataShouldNotHaveTh.js
@@ -1,6 +1,6 @@
var IsDataTableComponent = require('IsDataTableComponent');
var Case = require('Case');
var select = require('dom-select');
var DOM = require('DOM');
var TableLayoutDataShouldNotHaveTh = {
run: function (test) {
test.get('$scope').find('table').each(function () {
Expand All @@ -9,7 +9,7 @@ var TableLayoutDataShouldNotHaveTh = {
});
test.add(_case);

if (select.all('th', this).length !== 0) {
if (DOM.scry('th', this).length !== 0) {
if (!IsDataTableComponent($(this))) {
_case.set({
status: 'failed'
Expand Down

0 comments on commit 1787f1d

Please sign in to comment.