Skip to content

Commit

Permalink
Improve viewport check (#1116)
Browse files Browse the repository at this point in the history
* warn instead of fail on tap delay

* add viewport check to websites and stories

* improve wording

* update test
  • Loading branch information
sebastianbenz authored Dec 17, 2020
1 parent 53951ba commit f23b914
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/linter/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ function testsForMode(type: LintMode) {
AmpImgAmpPixelPreferred,
EndpointsAreAccessibleFromOrigin,
EndpointsAreAccessibleFromCache,
ViewportDisablesTapDelay,
]);
tests.set(
LintMode.AmpStory,
Expand All @@ -131,6 +132,7 @@ function testsForMode(type: LintMode) {
VideosHaveAltText,
VideosAreSubtitled,
TitleMeetsLengthCriteria,
ViewportDisablesTapDelay,
])
);
tests.set(
Expand Down
6 changes: 4 additions & 2 deletions packages/linter/src/rules/ViewportDisablesTapDelay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ export class ViewportDisablesTapDelay extends Rule {
return this.pass();
}
return viewport.attribs.content !== "width=device-width"
? this.fail(`Viewport width not set to device width`)
? this.warn(
`Viewport width is not set to device width: '<meta name="viewport" content="width=device-width">'`
)
: this.pass();
}
meta() {
return {
url:
"https://developers.google.com/web/updates/2013/12/300ms-tap-delay-gone-away",
title:
"Set viewport width to the same as the device to disable touch delay causing FID.",
"Set viewport width to match the device to disable touch delay causing FID.",
info: "",
};
}
Expand Down
2 changes: 1 addition & 1 deletion packages/linter/tests/local.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ describe(ViewportDisablesTapDelay.name, () => {
});

it(`${ViewportDisablesTapDelay.name} - Viewport causes Tap Delay`, async () => {
return assertFail(
return assertWarn(
runLocalTest(
ViewportDisablesTapDelay,
`${__dirname}/local/ViewportDisablesTapDelay-2/source.html`
Expand Down

0 comments on commit f23b914

Please sign in to comment.