Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 3.0.0 #98

Merged
merged 24 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8ca2d2d
added changes for build process
SwarajGK Sep 11, 2024
01d91e9
:robot: Automated formatting fixes
SwarajGK Sep 11, 2024
80bf267
Updated axe-core files for 200% zoom
Sep 11, 2024
aceb5cd
Adressed issue
Sep 18, 2024
ace6841
Adressed issue
Sep 18, 2024
9fa53cb
Merge branch 'main' of github.com:browserstack/a11y-engine-axe-core i…
Sep 18, 2024
19077ec
Adressed issue
Sep 19, 2024
7bc9186
Adressed issue
Sep 19, 2024
05e2ce4
Merge branch 'main' of github.com:browserstack/a11y-engine-axe-core i…
SwarajGK Sep 19, 2024
f1c08a4
Merge branch 'dom-forge-build-changes' of github.com:browserstack/a11…
SwarajGK Sep 19, 2024
49c223f
Reverted to cache method
Sep 19, 2024
6950c10
Reverted to cache method
Sep 19, 2024
6a26aa6
Added fix in getCellFromPoint in create-grid.js for 200% zoom
Sep 20, 2024
0b61ea2
Merge branch 'dom-forge-build-changes' of github.com:browserstack/a11…
SwarajGK Sep 25, 2024
5cd4a1f
Updated rule name
Oct 3, 2024
6b98646
Added safety to a11yEngineErrors
chikara1608 Oct 7, 2024
77cf978
Merge remote-tracking branch 'origin/release-3.0.0' into AXE-570_a11y…
chikara1608 Oct 8, 2024
f6d19ff
Merge branch 'main' of github.com:browserstack/a11y-engine-axe-core i…
Oct 8, 2024
a59be20
Merge branch 'release-3.0.0' into AXE-570_a11yEngineErrors
chikara1608 Oct 8, 2024
1f811bf
Merge pull request #103 from browserstack/AXE-570_a11yEngineErrors
ansh21 Oct 9, 2024
5610917
Revert "Fix: AXE-570 Fixed a11yEngineErrors being accessed on undefined"
ansh21 Oct 9, 2024
a8b0958
Merge pull request #104 from browserstack/revert-103-AXE-570_a11yEngi…
ansh21 Oct 9, 2024
3251c8c
Revert "Revert "Fix: AXE-570 Fixed a11yEngineErrors being accessed on…
ansh21 Oct 9, 2024
822d241
Merge pull request #105 from browserstack/revert-104-revert-103-AXE-5…
chikara1608 Oct 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build/tasks/esbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module.exports = function (grunt) {
entryPoints: [entry],
outfile: path.join(dest, name),
minify: false,
format: 'esm',
bundle: true
})
.then(done)
Expand Down
29 changes: 25 additions & 4 deletions lib/commons/dom/create-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export default function createGrid(
) {
// Prevent multiple calls per run
if (cache.get('gridCreated') && !parentVNode) {
// a11y-engine-domforge change
if (cache.get('gridSize')) {
return cache.get('gridSize');
}
Abhi3685 marked this conversation as resolved.
Show resolved Hide resolved
return constants.gridSize;
}
cache.set('gridCreated', true);
Expand Down Expand Up @@ -110,6 +114,11 @@ export default function createGrid(

node = treeWalker.nextNode();
}

// a11y-engine-domforge change
if (cache.get('gridSize')) {
return cache.get('gridSize');
}
return constants.gridSize;
}

Expand Down Expand Up @@ -430,6 +439,10 @@ class Grid {
* @returns {number}
*/
toGridIndex(num) {
// a11y-engine-domforge change
if (cache.get('gridSize')) {
return Math.floor(num / cache.get('gridSize'));
}
return Math.floor(num / constants.gridSize);
}

Expand All @@ -442,10 +455,18 @@ class Grid {
assert(this.boundaries, 'Grid does not have cells added');
const rowIndex = this.toGridIndex(y);
const colIndex = this.toGridIndex(x);
assert(
isPointInRect({ y: rowIndex, x: colIndex }, this.boundaries),
'Element midpoint exceeds the grid bounds'
);

// a11y-engine-domforge change
if (cache.get('ruleId') === 'resize-2x-zoom') {
if (!isPointInRect({ y: rowIndex, x: colIndex }, this.boundaries)) {
return [];
}
} else {
assert(
isPointInRect({ y: rowIndex, x: colIndex }, this.boundaries),
'Element midpoint exceeds the grid bounds'
);
}
const row = this.cells[rowIndex - this.cells._negativeIndex] ?? [];
return row[colIndex - row._negativeIndex] ?? [];
}
Expand Down
14 changes: 12 additions & 2 deletions lib/commons/dom/get-element-stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import createGrid from './create-grid';
* @param {Node} node
* @return {Node[]}
*/
function getElementStack(node) {

// Additional props isCoordsPassed, x, y for a11y-engine-domforge
function getElementStack(node, isCoordsPassed = false, x = null, y = null) {
createGrid();

const vNode = getNodeFromTree(node);
Expand All @@ -19,7 +21,15 @@ function getElementStack(node) {
return [];
}

return getRectStack(grid, vNode.boundingClientRect);
// Additional props isCoordsPassed, x, y for a11y-engine-domforge
return getRectStack(
grid,
vNode.boundingClientRect,
false,
isCoordsPassed,
x,
y
);
}

export default getElementStack;
16 changes: 14 additions & 2 deletions lib/commons/dom/get-overflow-hidden-ancestors.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import cache from '../../core/base/cache';
import memoize from '../../core/utils/memoize';

/**
Expand All @@ -17,8 +18,19 @@ const getOverflowHiddenAncestors = memoize(

const overflow = vNode.getComputedStylePropertyValue('overflow');

if (overflow === 'hidden') {
ancestors.push(vNode);
// a11y-engine-domforge change
if (cache.get('ruleId') && cache.get('ruleId') === 'resize-2x-zoom') {
if (
overflow.includes('hidden') ||
overflow.includes('clip') ||
overflow.includes('scroll')
) {
ancestors.push(vNode);
}
} else {
if (overflow.includes('hidden')) {
ancestors.push(vNode);
}
}

return ancestors.concat(getOverflowHiddenAncestors(vNode.parent));
Expand Down
21 changes: 18 additions & 3 deletions lib/commons/dom/get-rect-stack.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
import visuallySort from './visually-sort';
import { getRectCenter } from '../math';

export function getRectStack(grid, rect, recursed = false) {
// Additional props isCoordsPassed, x, y for a11y-engine-domforge
export function getRectStack(
grid,
rect,
recursed = false,
Abhi3685 marked this conversation as resolved.
Show resolved Hide resolved
isCoordsPassed = false,
x = null,
y = null
) {
const center = getRectCenter(rect);
const gridCell = grid.getCellFromPoint(center) || [];

const floorX = Math.floor(center.x);
const floorY = Math.floor(center.y);
let floorX = Math.floor(center.x);
let floorY = Math.floor(center.y);

// a11y-engine-domforge change
if (isCoordsPassed) {
floorX = Math.floor(x);
floorY = Math.floor(y);
}

let stack = gridCell.filter(gridCellNode => {
return gridCellNode.clientRects.some(clientRect => {
const rectX = clientRect.left;
Expand Down
13 changes: 11 additions & 2 deletions lib/commons/dom/get-visible-child-text-rects.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { getNodeFromTree, memoize } from '../../core/utils';
import { sanitize } from '../text';
import { getRectCenter, isPointInRect, getIntersectionRect } from '../math';
import { getIntersectionRect, getRectCenter, isPointInRect } from '../math';
import getOverflowHiddenAncestors from './get-overflow-hidden-ancestors';
import cache from '../../core/base/cache';

/**
* Get the visible text client rects of a node.
Expand All @@ -23,13 +24,21 @@ const getVisibleChildTextRects = memoize(
}

const contentRects = getContentRects(textNode);
if (isOutsideNodeBounds(contentRects, nodeRect)) {
if (isOutsideNodeBounds(contentRects, nodeRect) && !cache.get('ruleId')) {
return;
}

clientRects.push(...filterHiddenRects(contentRects, overflowHiddenNodes));
});

// a11y-engine-domforge change
if (
clientRects.length <= 0 &&
cache.get('ruleId') &&
cache.get('ruleId') === 'resize-2x-zoom'
) {
return [];
}
/**
* if all text rects are larger than the bounds of the node,
* or goes outside of the bounds of the node, we need to use
Expand Down
5 changes: 4 additions & 1 deletion lib/core/public/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ function runCommand(data, keepalive, callback) {
//a11y-engine iframe rules error merging logic
const errors = a11yEngine.getErrors();
if (Object.keys(errors).length !== 0) {
if (results[results.length - 1].a11yEngineErrors) {
if (
results.length > 0 &&
results[results.length - 1]?.a11yEngineErrors
) {
const error = results.pop();
delete error.a11yEngineErrors;
const mergedErrors = mergeErrors(error, errors);
Expand Down
5 changes: 4 additions & 1 deletion lib/core/public/run-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ export default function runRules(context, options, resolve, reject) {
// after should only run once, so ensure we are in the top level window
if (context.initiator) {
// Return a11y-engine errors when at top level window
if (results[results.length - 1].a11yEngineErrors) {
if (
results.length > 0 &&
results[results.length - 1]?.a11yEngineErrors
) {
const error = results.pop();
delete error.a11yEngineErrors;
a11yEngine.mergeErrors(error);
Expand Down
2 changes: 1 addition & 1 deletion lib/core/utils/merge-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function mergeResults(frameResults, options) {

const frameSpec = getFrameSpec(frameResult);
// Extract existing errors and merge with new ones
if (results[results.length - 1].a11yEngineErrors) {
if (results.length > 0 && results[results.length - 1]?.a11yEngineErrors) {
const error = results.pop();
delete error.a11yEngineErrors;
mergedErrors = mergeErrors(mergedErrors, error, frameSpec);
Expand Down
Loading