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

Consider element with height or width of 0 as invisible unless the text overflows #827

Merged
merged 47 commits into from
Jun 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
a2c09e0
Add basic tests for R11 (#770)
Jym77 Apr 20, 2021
b3b3d06
Remove second expectation from R62 (#772)
Jym77 Apr 21, 2021
53089a6
Implement pseudo classes equality (#773)
Jym77 Apr 21, 2021
6aac6f4
Name computation: skip step 1 when descending (#778)
Jym77 Apr 27, 2021
e6fb3bb
SIA R62: accept different font weight (#779)
Jym77 Apr 29, 2021
39be660
Extended diagnostic for R14 (#786)
Jym77 May 4, 2021
597c2a1
Fix background size (#788)
Jym77 May 4, 2021
8b586a4
Assume no background on size (#789)
Jym77 May 4, 2021
62d1132
SIA R17: add test (#791)
elenamongelli May 7, 2021
a78c527
SIA R4: test added (#793)
elenamongelli May 7, 2021
69ea3cd
SIA R3: add test (#792)
elenamongelli May 7, 2021
4f5fddd
R6 test added (#795)
elenamongelli May 7, 2021
b5f2dd6
Run prettier
Jym77 May 7, 2021
0c2977c
Add --immutable flag to install instruction, add intructions for runn…
Jym77 May 7, 2021
f66b35e
Simplify double negative
Jym77 May 11, 2021
6bc0448
SIA R5: add test (#794)
elenamongelli May 11, 2021
96f6a4c
SIA R12: Add Test (#800)
elenamongelli May 17, 2021
46eed6f
Fix hasRole to pick the role from the accessible node (#805)
Jym77 May 17, 2021
39fbaad
Merge branch 'main' into develop
Jym77 May 17, 2021
71d5482
Clean up
Jym77 May 17, 2021
3129b13
R18 add test (#803)
elenamongelli May 17, 2021
1a8b05b
SIA-R19: Add test (#807)
elenamongelli May 18, 2021
0378d6f
SIA-R8: Added tests (#806)
elenamongelli May 18, 2021
98237ce
R16 extended diagnostic (#804)
elenamongelli May 19, 2021
6ec7b83
Clean up test descriptions a bit
Jym77 May 19, 2021
e5950db
Use n-ary and to streamline code
Jym77 May 21, 2021
0b0d863
R62 extended diagnostic (#801)
elenamongelli May 26, 2021
c2333b8
Send shorthands for border
Jym77 May 26, 2021
1d39a93
Avoid sending styles that are equals to initial
Jym77 May 26, 2021
456d060
Avoid sending styles that are equals to initial
Jym77 May 26, 2021
e1b4cf0
Send shorthands for outline
Jym77 May 28, 2021
314a272
Send shorthand for text-decoration
Jym77 May 28, 2021
4a8bc76
Support text-decoration-thickness (#817)
Jym77 May 28, 2021
24fa3fb
Merge branch 'main' into develop
Jym77 May 28, 2021
afd1c50
Remove unused imports
Jym77 May 28, 2021
8f0338d
Increase Nodejs heap size (#818)
Jym77 May 28, 2021
3b282b6
SIA R65: accept different border as focus indicator (#819)
Jym77 Jun 1, 2021
dcecc1f
Remove 'found' which is not used by frontend
Jym77 Jun 1, 2021
a087aa5
Fix serialisation of outline
Jym77 Jun 2, 2021
da6a10f
Heap size problem and investigation. (#822)
Jym77 Jun 2, 2021
da99401
Support `font-variant` CSS property (#821)
Jym77 Jun 2, 2021
452bc78
Test for SIA-R20 added
elenamongelli Jun 8, 2021
de8a225
Checks for overflow auto, scroll added in both rules and tests
elenamongelli Jun 8, 2021
daf6b5f
Comments have been integrated
elenamongelli Jun 9, 2021
b6380d3
Merge branch 'main' into is-clipped-update
Jym77 Jun 14, 2021
322ed4f
Clean up
Jym77 Jun 14, 2021
d7be9b4
Merge branch 'main' into is-clipped-update
Jym77 Jun 16, 2021
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
31 changes: 28 additions & 3 deletions packages/alfa-rules/src/common/predicate/is-clipped.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ function isClippedBySize(
const { value: x } = style.computed("overflow-x");
const { value: y } = style.computed("overflow-y");

if (x.value === "hidden" || y.value === "hidden") {
const { value: height } = style.computed("height");
const { value: width } = style.computed("width");
const { value: height } = style.computed("height");
const { value: width } = style.computed("width");

if (x.value === "hidden" || y.value === "hidden") {
for (const dimension of [height, width]) {
switch (dimension.type) {
case "percentage":
Expand All @@ -64,6 +64,31 @@ function isClippedBySize(
}
}
}

if (
x.value === "auto" ||
x.value === "scroll" ||
y.value === "auto" ||
y.value === "scroll"
) {
for (const dimension of [height, width]) {
switch (dimension.type) {
case "percentage":
if (dimension.value <= 0) {
return true;
} else {
break;
}

case "length":
if (dimension.value <= 0) {
return true;
} else {
break;
}
}
}
}
}

for (const parent of node.parent({ flattened: true })) {
Expand Down
36 changes: 36 additions & 0 deletions packages/alfa-rules/test/common/predicate/is-visible.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,42 @@ test(`isVisible() returns false when an element is hidden by reducing its size
t.equal(isVisible(element), false);
});

test(`isVisible() returns false when an element scrolls its overflow and its size is reduced to 0 pixel, thus hidding the scrollbar`, (t) => {
for (const element of [
<div style={{ width: "0", overflowX: "scroll" }}>Hello World</div>,

<div style={{ width: "0", overflowY: "scroll" }}>Hello World</div>,

<div style={{ height: "0", overflowX: "scroll" }}>Hello World</div>,

<div style={{ height: "0", overflowY: "scroll" }}>Hello World</div>,

<div style={{ width: "0", height: "0", overflow: "scroll" }}>
Hello World
</div>,
]) {
t.equal(isVisible(element), false);
}
});

test(`isVisible() returns false when an element has its overflow set to auto and its size is reduced to 0 pixel, thus hidding the scrollbar`, (t) => {
for (const element of [
<div style={{ width: "0", overflowX: "auto" }}>Hello World</div>,

<div style={{ width: "0", overflowY: "auto" }}>Hello World</div>,

<div style={{ height: "0", overflowX: "auto" }}>Hello World</div>,

<div style={{ height: "0", overflowY: "auto" }}>Hello World</div>,

<div style={{ width: "0", height: "0", overflow: "auto" }}>
Hello World
</div>,
]) {
t.equal(isVisible(element), false);
}
});

test("isVisible() returns false on empty elements", (t) => {
const element = <div />;

Expand Down