Skip to content

Commit

Permalink
fix(meta-viewport): don't throw error if viewport property doesn't ha…
Browse files Browse the repository at this point in the history
…ve a value (#2238)

* fix(meta-viewport): don't throw error if viewport property doesn't have a value

* Update lib/checks/mobile/meta-viewport-scale-evaluate.js

Co-authored-by: Stephen Mathieson <me@stephenmathieson.com>

* Exit early

Co-authored-by: Stephen Mathieson <me@stephenmathieson.com>
  • Loading branch information
mattzeunert and stephenmathieson authored May 18, 2020
1 parent 20467aa commit 7088c7a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/checks/mobile/meta-viewport-scale-evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ function metaViewportScaleEvaluate(node, options) {
}

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

Expand Down
8 changes: 8 additions & 0 deletions test/checks/mobile/meta-viewport-scale.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ describe('meta-viewport', function() {
axe.testUtils.getCheckEvaluate('meta-viewport').call(checkContext, node)
);
});

it('should not crash if viewport property does not have a value', function() {
fixture.innerHTML =
'<meta name="viewport" content="user-scalable=1, minimal-ui">';
var node = fixture.querySelector('meta');

assert.isTrue(axe.testUtils.getCheckEvaluate('meta-viewport')(node));
});
});

describe(', separator', function() {
Expand Down

0 comments on commit 7088c7a

Please sign in to comment.