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

Commit

Permalink
Added first round of tests for changing meaning through positioning per
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Miller committed Feb 17, 2014
1 parent 45c620d commit 8d26e3e
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 1 deletion.
30 changes: 30 additions & 0 deletions src/js/custom/contentPositioningShouldNotChangeMeaning.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
quail.contentPositioningShouldNotChangeMeaning = function() {
//Look for absolute positioned elements that are being put into grids or columns
var positions = ['top', 'left', 'right', 'bottom'];
var coordinates = {};
var failed = false;
quail.html.find('*:has(*:quailCss(position=absolute))').each(function() {
coordinates = {top: {}, left: {}, right: {}, bottom: {}};
failed = false;
var $container = $(this);
$container.find('li, ul, dd, dt').filter(':quailCss(position=absolute)').each(function() {
for(var i = 0; i < positions.length; i++) {
if(typeof $(this).css(positions[i]) !== 'undefined' && $(this).css(positions[i]) !== 'auto') {
if(typeof coordinates[positions[i]][$(this).css(positions[i])] === 'undefined') {
coordinates[positions[i]][$(this).css(positions[i])] = 0;
}
coordinates[positions[i]][$(this).css(positions[i])]++;
}
}
});

$.each(positions, function() {
$.each(coordinates[this], function() {
if(this > 2 && !failed) {
failed = true;
quail.testFails('contentPositioningShouldNotChangeMeaning', $container);
}
});
});
});
};
26 changes: 26 additions & 0 deletions src/resources/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,32 @@ checkboxLabelIsNearby:
- "labelProximity"
options:
selector: "input[type=checkbox]"
contentPositioningShouldNotChangeMeaning:
type: "custom"
testability: 0.5
title:
en: "Meaning should not be created through positioning"
description:
en: "Positioning should not be used to change the meaning of an element."
guidelines:
wcag:
1.3.2:
techniques:
- "C6"
- "F1"
1.4.5:
techniques:
- "C6"
1.4.9:
techniques:
- "C6"
2.4.1:
techniques:
- "C6"
tags:
- "content"
- "structure"
callback: "contentPositioningShouldNotChangeMeaning"
cssDocumentMakesSenseStyleTurnedOff:
type: "selector"
testability: 0
Expand Down
Loading

0 comments on commit 8d26e3e

Please sign in to comment.