Sha256: 5a03e1102b7195f2b893a0d0887c15c72b2c900c08b969831a0bfa9c4d1bd2d5

Contents?: true

Size: 1.1 KB

Versions: 202

Compression:

Stored size: 1.1 KB

Contents

const { scaleMinimum = 2, lowerBound = false } = options || {};

const content = node.getAttribute('content') || '';
if (!content) {
	return true;
}

const result = content.split(/[;,]/).reduce((out, item) => {
	const contentValue = item.trim();
	if (!contentValue) {
		return out;
	}

	const [key, value] = contentValue.split('=');
	if (!key || !value) {
		return out;
	}
	const curatedKey = key.toLowerCase().trim();
	let curatedValue = value.toLowerCase().trim();

	// convert `yes` to `1`
	if (curatedKey === 'maximum-scale' && curatedValue === 'yes') {
		curatedValue = 1;
	}
	// when negative ignore key
	if (curatedKey === 'maximum-scale' && parseFloat(curatedValue) < 0) {
		return out;
	}

	out[curatedKey] = curatedValue;
	return out;
}, {});

if (
	lowerBound &&
	result['maximum-scale'] &&
	parseFloat(result['maximum-scale']) < lowerBound
) {
	return true;
}

if (!lowerBound && result['user-scalable'] === 'no') {
	this.data('user-scalable=no');
	return false;
}

if (
	result['maximum-scale'] &&
	parseFloat(result['maximum-scale']) < scaleMinimum
) {
	this.data('maximum-scale');
	return false;
}

return true;

Version data entries

202 entries across 202 versions & 1 rubygems

Version Path
govuk_publishing_components-30.4.1 node_modules/axe-core/lib/checks/mobile/meta-viewport-scale.js
govuk_publishing_components-30.4.0 node_modules/axe-core/lib/checks/mobile/meta-viewport-scale.js
govuk_publishing_components-30.3.0 node_modules/axe-core/lib/checks/mobile/meta-viewport-scale.js
govuk_publishing_components-30.2.1 node_modules/axe-core/lib/checks/mobile/meta-viewport-scale.js
govuk_publishing_components-30.2.0 node_modules/axe-core/lib/checks/mobile/meta-viewport-scale.js
govuk_publishing_components-30.1.0 node_modules/axe-core/lib/checks/mobile/meta-viewport-scale.js
govuk_publishing_components-30.0.0 node_modules/axe-core/lib/checks/mobile/meta-viewport-scale.js
govuk_publishing_components-29.15.3 node_modules/axe-core/lib/checks/mobile/meta-viewport-scale.js
govuk_publishing_components-29.15.2 node_modules/axe-core/lib/checks/mobile/meta-viewport-scale.js
govuk_publishing_components-29.15.1 node_modules/axe-core/lib/checks/mobile/meta-viewport-scale.js
govuk_publishing_components-29.15.0 node_modules/axe-core/lib/checks/mobile/meta-viewport-scale.js
govuk_publishing_components-29.14.0 node_modules/axe-core/lib/checks/mobile/meta-viewport-scale.js
govuk_publishing_components-29.13.0 node_modules/axe-core/lib/checks/mobile/meta-viewport-scale.js
govuk_publishing_components-29.12.1 node_modules/axe-core/lib/checks/mobile/meta-viewport-scale.js
govuk_publishing_components-29.12.0 node_modules/axe-core/lib/checks/mobile/meta-viewport-scale.js
govuk_publishing_components-29.11.0 node_modules/axe-core/lib/checks/mobile/meta-viewport-scale.js
govuk_publishing_components-29.10.0 node_modules/axe-core/lib/checks/mobile/meta-viewport-scale.js
govuk_publishing_components-29.9.0 node_modules/axe-core/lib/checks/mobile/meta-viewport-scale.js
govuk_publishing_components-29.8.0 node_modules/axe-core/lib/checks/mobile/meta-viewport-scale.js
govuk_publishing_components-29.7.0 node_modules/axe-core/lib/checks/mobile/meta-viewport-scale.js