Skip to content

Commit

Permalink
refactor(aria.js): move cleanup into main scope
Browse files Browse the repository at this point in the history
Note: removes skipindex check during cleanup.

test.sh run is clean.
  • Loading branch information
pkra committed Dec 13, 2023
1 parent 22aac2a commit 72781f9
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions script/aria.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,32 @@ const buildInheritedStatesProperties = function (item) {
}
};

/**
* prune out unused rows throughout the document
*
*/
const pruneUnusedRows = () => {
document
.querySelectorAll(
".role-abstract, .role-parent, .role-base, .role-related, .role-scope, .role-mustcontain, .role-required-properties, .role-properties, .role-namefrom, .role-namerequired, .role-namerequired-inherited, .role-childpresentational, .role-presentational-inherited, .state-related, .property-related,.role-inherited, .role-children, .property-descendants, .state-descendants, .implicit-values"
)
.forEach(function (item) {
var content = item.innerText;
if (content.length === 1 || content.length === 0) {
// there is no item - remove the row
item.parentNode.parentNode.removeChild(item.parentNode);
} else if (
content === "Placeholder" &&
(item.className === "role-inherited" ||
item.className === "role-children" ||
item.className === "property-descendants" ||
item.className === "state-descendants")
) {
item.parentNode.remove();
}
});
};

function ariaAttributeReferences() {
const propList = {};
const globalSP = [];
Expand Down Expand Up @@ -595,27 +621,7 @@ function ariaAttributeReferences() {
});
}

// prune out unused rows throughout the document
document
.querySelectorAll(
".role-abstract, .role-parent, .role-base, .role-related, .role-scope, .role-mustcontain, .role-required-properties, .role-properties, .role-namefrom, .role-namerequired, .role-namerequired-inherited, .role-childpresentational, .role-presentational-inherited, .state-related, .property-related,.role-inherited, .role-children, .property-descendants, .state-descendants, .implicit-values"
)
.forEach(function (item) {
var content = item.innerText;
if (content.length === 1 || content.length === 0) {
// there is no item - remove the row
item.parentNode.parentNode.removeChild(item.parentNode);
} else if (
content === "Placeholder" &&
!skipIndex &&
(item.className === "role-inherited" ||
item.className === "role-children" ||
item.className === "property-descendants" ||
item.className === "state-descendants")
) {
item.parentNode.remove();
}
});
pruneUnusedRows();

updateReferences(document);
}
Expand Down

0 comments on commit 72781f9

Please sign in to comment.