metaviewport-parser
Advanced tools
Comparing version 0.1.0 to 0.2.0
14
index.js
@@ -19,2 +19,3 @@ exports.getRenderingDataFromViewport = function (viewportProperties, uaDeviceWidth, uaDeviceHeight, uaMaxZoom, uaMinZoom) { | ||
var userZoom = "zoom"; | ||
if (viewportProperties["maximum-scale"] !== undefined) { | ||
@@ -275,3 +276,3 @@ maxZoom = translateZoomProperty(viewportProperties["maximum-scale"]); | ||
var propertyNames = ["width", "height", "initial-scale", "minimum-scale", "maximum-scale", "user-scalable", "shrink-to-fit"]; | ||
var propertyNames = ["width", "height", "initial-scale", "minimum-scale", "maximum-scale", "user-scalable", "shrink-to-fit", "viewport-fit"]; | ||
@@ -316,6 +317,12 @@ function parseProperty(parsedContent, S, i) { | ||
var string = value.toLowerCase(); | ||
if (string === "yes" || string === "no" || string === "device-width" || string === "device-height") { | ||
if (string === "yes" || string === "no" || string === "device-width" || string === "device-height" || | ||
// https://webkit.org/blog/7929/designing-websites-for-iphone-x/ | ||
(name.toLowerCase() === 'viewport-fit' && (string === 'auto' || string === 'cover'))) { | ||
parsedContent.validProperties[name] = string; | ||
return; | ||
} | ||
parsedContent.validProperties[name] = null; | ||
@@ -335,3 +342,4 @@ parsedContent.invalidValues[name] = value; | ||
"user-scalable": ["yes", "no", "0", "1"], | ||
"shrink-to-fit": ["yes", "no"] | ||
"shrink-to-fit": ["yes", "no"], | ||
"viewport-fit": ["auto", "cover"] | ||
}; |
{ | ||
"name": "metaviewport-parser", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Parser for the content attribute of the meta viewport", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
13
test.js
@@ -35,4 +35,13 @@ var metaparser = require("./index") | ||
{desc: "handle bad safari shrink-to-fit value", | ||
inp:"shrink-to-fit=foo", | ||
out: buildParsedContent({"shrink-to-fit":null},null, {"shrink-to-fit": "foo"})}, | ||
inp:"shrink-to-fit=foo", | ||
out: buildParsedContent({"shrink-to-fit":null},null, {"shrink-to-fit": "foo"})}, | ||
{desc: "handle safari viewport-fit", | ||
inp:"initial-scale=1; viewport-fit=auto", | ||
out: buildParsedContent({"initial-scale": 1, "viewport-fit":"auto"})}, | ||
{desc: "handle safari viewport-fit=cover", | ||
inp:"initial-scale=1; viewport-fit=cover", | ||
out: buildParsedContent({"initial-scale": 1, "viewport-fit":"cover"})}, | ||
{desc: "handle bad safari viewport-fit value", | ||
inp:"viewport-fit=foo", | ||
out: buildParsedContent({"viewport-fit":null}, null, {"viewport-fit": "foo"})}, | ||
{desc: "handle whitespace correctly", | ||
@@ -39,0 +48,0 @@ inp:" width=400\ |
25184
389