Skip to content

Commit 68f7e76

Browse files
author
michael-n-cooper
committed
TRAVIS-CI update from aria-common
1 parent 5b8f0b2 commit 68f7e76

File tree

1 file changed

+89
-17
lines changed

1 file changed

+89
-17
lines changed

common/script/aria.js

Lines changed: 89 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,14 @@ require(["core/pubsubhub"], function( respecEvents ) {
172172
propList[title] = { is: type, title: title, name: content, desc: desc, roles: [] };
173173
var abstract = container.querySelector("." + type + "-applicability");
174174
if ((abstract.textContent || abstract.innerText) === "All elements of the base markup") {
175-
globalSP.push({ is: type, title: title, name: content, desc: desc, prohibited: false });
176-
}
175+
globalSP.push({ is: type, title: title, name: content, desc: desc, prohibited: false, deprecated: false });
176+
}
177177
else if ((abstract.textContent || abstract.innerText) === "All elements of the base markup except for some roles or elements that prohibit its use") {
178-
globalSP.push({ is: type, title: title, name: content, desc: desc, prohibited: true });
178+
globalSP.push({ is: type, title: title, name: content, desc: desc, prohibited: true, deprecated: false });
179179
}
180-
180+
else if ((abstract.textContent || abstract.innerText) === "Use as a global deprecated in ARIA 1.2") {
181+
globalSP.push({ is: type, title: title, name: content, desc: desc, prohibited: false, deprecated: true });
182+
}
181183
// the rdef is gone. if we are in a div, convert that div to a section
182184

183185
if (container.nodeName.toLowerCase() == "div") {
@@ -222,13 +224,16 @@ require(["core/pubsubhub"], function( respecEvents ) {
222224
var lItem = sortedList[i];
223225
globalSPIndex += "<li>";
224226
if (lItem.is === "state") {
225-
globalSPIndex += "<sref title=\"" + lItem.name + "\">" + lItem.name + " (state)</sref>";
227+
globalSPIndex += "<sref "+(lItem.prohibited?"data-prohibited ":"")+(lItem.deprecated?"data-deprecated ":"") +"title=\"" + lItem.name + "\">" + lItem.name + " (state)</sref>";
226228
} else {
227-
globalSPIndex += "<pref>" + lItem.name + "</pref>";
229+
globalSPIndex += "<pref "+(lItem.prohibited?"data-prohibited ":"")+(lItem.deprecated?"data-deprecated ":"") +">" + lItem.name + "</pref>";
228230
}
229231
if (lItem.prohibited) {
230232
globalSPIndex += " (Except where prohibited)";
231233
}
234+
if (lItem.deprecated) {
235+
globalSPIndex += " (Global use deprecated in ARIA 1.2)"
236+
}
232237
globalSPIndex += "</li>\n";
233238
}
234239
parentNode = document.querySelector("#global_states");
@@ -330,8 +335,9 @@ require(["core/pubsubhub"], function( respecEvents ) {
330335
var type = (item.localName === "pref" ? "property" : "state");
331336
var req = $(node).hasClass("role-required-properties");
332337
var dis = $(node).hasClass("role-disallowed");
333-
attrs.push( { is: type, name: name, required: req, disallowed: dis } );
334-
338+
var dep = item.hasAttribute("data-deprecated");
339+
attrs.push( { is: type, name: name, required: req, disallowed: dis, deprecated: dep } );
340+
335341
// remember that the state or property is
336342
// referenced by this role
337343
propList[name].roles.push(title);
@@ -419,24 +425,41 @@ require(["core/pubsubhub"], function( respecEvents ) {
419425
});
420426
}
421427
}
422-
var sortedList = [];
423-
sortedList = myList.sort(function(a,b) { return a.name < b.name ? -1 : a.name > b.name ? 1 : 0 });
428+
429+
var reducedList = myList.reduce((uniqueList, item) => {
430+
return uniqueList.includes(item) ? uniqueList : [...uniqueList, item]
431+
}, [] )
432+
433+
var sortedList = reducedList.sort((a,b) => {
434+
if (a.name == b.name) {
435+
// Ensure deprecated false properties occur first
436+
if (a.deprecated !== b.deprecated) {
437+
return a.deprecated ? 1 : b.deprecated ? -1 : 0
438+
}
439+
}
440+
return a.name < b.name ? -1 : a.name > b.name ? 1 : 0
441+
}, [] )
442+
424443
var prev;
425444
for (var k = 0; k < sortedList.length; k++) {
426-
var role = sortedList[k];
445+
var property = sortedList[k];
427446
var req = "";
428-
if (role.required) {
447+
var dep = "";
448+
if (property.required) {
429449
req = " <strong>(required)</strong>";
430450
}
431-
if (prev != role.name) {
451+
if (property.deprecated) {
452+
dep = " <strong>(deprecated on this role in ARIA 1.2)</strong>"
453+
}
454+
if (prev != property.name) {
432455
output += "<li>";
433-
if (role.is === "state") {
434-
output += "<sref title=\"" + role.name + "\">" + role.name + " (state)</sref>" + req;
456+
if (property.is === "state") {
457+
output += "<sref>" + property.name + "</sref> (state)" + req + dep;
435458
} else {
436-
output += "<pref>" + role.name + "</pref>" + req;
459+
output += "<pref>" + property.name + "</pref>" + req + dep;
437460
}
438461
output += "</li>\n";
439-
prev = role.name;
462+
prev = property.name;
440463
}
441464
}
442465
if (output !== "") {
@@ -510,6 +533,55 @@ require(["core/pubsubhub"], function( respecEvents ) {
510533
placeholder.innerHTML = output;
511534
}
512535
}
536+
else if (placeholder && (((placeholder.textContent || placeholder.innerText) ==="Use as a global deprecated in ARIA 1.2")) && item.roles.length)
537+
{
538+
// update the used in roles list
539+
var sortedList = [];
540+
sortedList = item.roles.sort();
541+
//remove roletype from the sorted list
542+
const index = sortedList.indexOf('roletype');
543+
if (index > -1) {
544+
sortedList.splice(index, 1);
545+
}
546+
547+
548+
for (var j = 0; j < sortedList.length; j++) {
549+
output += "<li><rref>" + sortedList[j] + "</rref></li>\n";
550+
}
551+
if (output !== "") {
552+
output = "<ul>\n" + output + "</ul>\n";
553+
}
554+
placeholder.innerHTML = output;
555+
// also update any inherited roles
556+
var myList = [];
557+
$.each(item.roles, function(j, role) {
558+
var children = getAllSubRoles(role);
559+
// Some subroles have required properties which are also required by the superclass.
560+
// Example: The checked state of radio, which is also required by superclass checkbox.
561+
// We only want to include these one time, so filter out the subroles.
562+
children = $.grep(children, function(subrole) {
563+
return $.inArray(subrole, propList[item.name].roles) == -1;
564+
});
565+
$.merge(myList, children);
566+
});
567+
placeholder = section.querySelector(".state-descendants, .property-descendants");
568+
if (placeholder && myList.length) {
569+
sortedList = myList.sort();
570+
output = "";
571+
var last = "";
572+
for (j = 0; j < sortedList.length; j++) {
573+
var sItem = sortedList[j];
574+
if (last != sItem) {
575+
output += "<li><rref>" + sItem + "</rref></li>\n";
576+
last = sItem;
577+
}
578+
}
579+
if (output !== "") {
580+
output = "<ul>\n" + output + "</ul>\n";
581+
}
582+
placeholder.innerHTML = output;
583+
}
584+
}
513585
});
514586

515587
// spit out the index

0 commit comments

Comments
 (0)