Skip to content

Commit

Permalink
Warn about viewport shrink-to-fit directive (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
rviscomi authored Apr 23, 2024
1 parent c9c6706 commit c8f04e2
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion crx/capo.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion crx/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "Capo: get your ﹤𝚑𝚎𝚊𝚍﹥ in order",
"description": "Visualize the optimal ordering of ﹤𝚑𝚎𝚊𝚍﹥ elements on any web page",
"version": "1.5.1",
"version": "1.5.2",
"permissions": [
"scripting",
"activeTab",
Expand Down
4 changes: 3 additions & 1 deletion docs/src/lib/capo.js
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,7 @@ function $c322f9a5057eaf5c$var$validateMetaViewport(element) {
];
if (!validValues.includes(interactiveWidget)) warnings.push(`Unsupported value "${interactiveWidget}" found.`);
}
if ("shrink-to-fit" in directives) warnings.push("The shrink-to-fit directive has been obsolete since iOS 9.2.\n See https://www.scottohara.me/blog/2018/12/11/shrink-to-fit.html");
const validDirectives = new Set([
"width",
"height",
Expand All @@ -900,7 +901,8 @@ function $c322f9a5057eaf5c$var$validateMetaViewport(element) {
"interactive-widget"
]);
Object.keys(directives).filter((directive)=>{
return !validDirectives.has(directive);
// shrink-to-fit is not valid, but we have a separate warning for it.
return !validDirectives.has(directive) && directive != "shrink-to-fit";
}).forEach((directive)=>{
warnings.push(`Invalid viewport directive "${directive}".`);
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rviscomi/capo.js",
"version": "1.5.1",
"version": "1.5.2",
"description": "Get your ﹤𝚑𝚎𝚊𝚍﹥ in order",
"author": "Rick Viscomi",
"license": "Apache-2.0",
Expand Down
4 changes: 3 additions & 1 deletion snippet/capo.js
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,7 @@ function $580f7ed6bc170ae8$var$validateMetaViewport(element) {
];
if (!validValues.includes(interactiveWidget)) warnings.push(`Unsupported value "${interactiveWidget}" found.`);
}
if ("shrink-to-fit" in directives) warnings.push("The shrink-to-fit directive has been obsolete since iOS 9.2.\n See https://www.scottohara.me/blog/2018/12/11/shrink-to-fit.html");
const validDirectives = new Set([
"width",
"height",
Expand All @@ -901,7 +902,8 @@ function $580f7ed6bc170ae8$var$validateMetaViewport(element) {
"interactive-widget"
]);
Object.keys(directives).filter((directive)=>{
return !validDirectives.has(directive);
// shrink-to-fit is not valid, but we have a separate warning for it.
return !validDirectives.has(directive) && directive != "shrink-to-fit";
}).forEach((directive)=>{
warnings.push(`Invalid viewport directive "${directive}".`);
});
Expand Down
9 changes: 8 additions & 1 deletion src/lib/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,12 @@ function validateMetaViewport(element) {
}
}

if ("shrink-to-fit" in directives) {
warnings.push(
"The shrink-to-fit directive has been obsolete since iOS 9.2.\n See https://www.scottohara.me/blog/2018/12/11/shrink-to-fit.html"
);
}

const validDirectives = new Set([
"width",
"height",
Expand All @@ -686,7 +692,8 @@ function validateMetaViewport(element) {
]);
Object.keys(directives)
.filter((directive) => {
return !validDirectives.has(directive);
// shrink-to-fit is not valid, but we have a separate warning for it.
return !validDirectives.has(directive) && directive != "shrink-to-fit";
})
.forEach((directive) => {
warnings.push(`Invalid viewport directive "${directive}".`);
Expand Down

0 comments on commit c8f04e2

Please sign in to comment.