Skip to content

Commit d9b9405

Browse files
authored
Merge pull request #158 from alvaromontoro/feature/no-user-zoom-warning
2 parents 9c5abce + d39bc79 commit d9b9405

10 files changed

Lines changed: 68 additions & 4 deletions

File tree

checka11y-warnings.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,22 @@
8686
background-color: var(--checka11y-bg-warning);
8787
}
8888

89+
head {
90+
display: block;
91+
}
92+
93+
head meta[name=viewport][content*="maximum-scale=1" i], head meta[name=viewport][content*="user-scalable=no" i] {
94+
border: 0.4rem solid;
95+
border-color: var(--checka11y-border-warning);
96+
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="458px" height="80px" viewBox="0 0 458 80"><rect class="box" x="4" y="4" width="450" height="72" rx="12" ry="12" fill="rgba(255, 255, 216, 0.999999)" stroke-width="0.4rem" stroke="rgba(255, 255, 102, 0.999999)" /><g fill="rgba(133, 100, 4, 0.999999)" font-size="1rem" font-weight="700" font-family="verdana, geneva, tahoma, sans-serif" font-style="initial" letter-spacing="initial" text-decoration="none" text-transform="initial" text-shadow="none"><text x="15" y="35">WARNING (W0016): The display zoom/scale</text> <text x="15" y="60">has been disabled.</text></g></svg>');
97+
background-position: bottom center;
98+
background-repeat: no-repeat;
99+
min-width: 458px;
100+
padding-bottom: 80px;
101+
display: block;
102+
border: 0;
103+
}
104+
89105
h1[role=text]::after, h2[role=text]::after, h3[role=text]::after, h4[role=text]::after, h5[role=text]::after, h6[role=text]::after {
90106
display: block;
91107
font-size: 1rem;

checka11y-warnings.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

checka11y.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,22 @@
8686
background-color: var(--checka11y-bg-warning);
8787
}
8888

89+
head {
90+
display: block;
91+
}
92+
93+
head meta[name=viewport][content*="maximum-scale=1" i], head meta[name=viewport][content*="user-scalable=no" i] {
94+
border: 0.4rem solid;
95+
border-color: var(--checka11y-border-warning);
96+
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="458px" height="80px" viewBox="0 0 458 80"><rect class="box" x="4" y="4" width="450" height="72" rx="12" ry="12" fill="rgba(255, 255, 216, 0.999999)" stroke-width="0.4rem" stroke="rgba(255, 255, 102, 0.999999)" /><g fill="rgba(133, 100, 4, 0.999999)" font-size="1rem" font-weight="700" font-family="verdana, geneva, tahoma, sans-serif" font-style="initial" letter-spacing="initial" text-decoration="none" text-transform="initial" text-shadow="none"><text x="15" y="35">WARNING (W0016): The display zoom/scale</text> <text x="15" y="60">has been disabled.</text></g></svg>');
97+
background-position: bottom center;
98+
background-repeat: no-repeat;
99+
min-width: 458px;
100+
padding-bottom: 80px;
101+
display: block;
102+
border: 0;
103+
}
104+
89105
h1[role=text]::after, h2[role=text]::after, h3[role=text]::after, h4[role=text]::after, h5[role=text]::after, h6[role=text]::after {
90106
display: block;
91107
font-size: 1rem;

checka11y.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codes.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,6 @@ A list of every Checka11y.css error & warning code with details on what the issu
148148

149149
- ### W0015
150150
The `longdesc` attribute has been detected in an `<img>`. The `longdesc` attribute in images is deprecated and should not be used. It is not fully supported by HTML5, browsers, or screen readers. When present, it is commonly misused (it should point to an URL that is not an image).
151+
152+
- ### W0016
153+
The `viewport` meta tag contains a property that disables the zoom and/or the viewport scale. Such a property may prevent users from interacting with the web page, and make it more difficult to view the content.

cypress/integration/head_spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,13 @@ describe("<head>", () => {
1111
.and('match', /data/)
1212
});
1313
});
14+
15+
it('should not disallow user zooming an', () => {
16+
cy.get('head meta[name="viewport"][content*="maximum-scale=1"i], head meta[name="viewport"][content*="user-scalable=no"i]')
17+
.each(element => {
18+
cy.get(element)
19+
.should('have.css', 'background-image') // yields data:image....
20+
.and('match', /data/)
21+
});
22+
});
1423
});

features.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,5 @@ A list of every a11y concern Checka11y.css will check for and highlight with lin
4141
- [W0012](./codes.md#W0012): Checks for heading element inside `<section>` element.
4242
- [W0013](./codes.md#W0013): Checks for anchor tags that contain a link to a PDF, Word, Excel, or PowerPoint document.
4343
- [W0014](./codes.md#W0014): Checks for anchor tags that contain a link to content site.
44-
- [W0015](./codes.md#W0014): Checks for images with the `longdesc` attribute.
44+
- [W0015](./codes.md#W0015): Checks for images with the `longdesc` attribute.
45+
- [W0016](./codes.md#W0016): Checks for zoom/scale being disabled in the meta `viewport`.

src/warnings/features/_head.scss

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@use "../../shared/messages/" as *;
2+
3+
/* Make the head visible to show the title. This could have side effects but,
4+
in theory, all the elements in the head are non-visible. So we should be ok :P */
5+
head {
6+
display: block;
7+
}
8+
9+
/* W0016: title element must not be empty */
10+
head meta[name="viewport"] {
11+
&[content*="maximum-scale=1" i],
12+
&[content*="user-scalable=no" i] {
13+
@include vectorMessage(warning, "W0016", 458, "The display zoom/scale", "has been disabled.");
14+
15+
display: block;
16+
border: 0;
17+
}
18+
}

src/warnings/features/_index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
@forward "./aria-hidden";
33
@forward "./autoplay";
44
@forward "./handlers";
5+
@forward "./head";
56
@forward "./headings";
67
@forward "./images";
78
@forward "./inline";

test/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<meta charset="UTF-8">
5-
<meta name="viewport" content="width=device-width,initial-scale=1">
5+
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
66
<title></title>
77
<link rel="stylesheet" href="./index.css" />
88
<link rel="stylesheet" href="../checka11y.css" />

0 commit comments

Comments
 (0)